Git Product home page Git Product logo

brave-clojure-web's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brave-clojure-web's Issues

Slight correction needed in the Emacs Configuration instructions?

Hi!
The Emacs page is excellent. However, under step 3 it says:

"Download the Emacs configuration zip file from the book’s resource page and unzip it. Its contents should be a folder, emacs-for-clojure-book1. Run mv path/to/emacs-for-clojure-book1 ~/.emacs.d."

I couldn't find the "resource page" and the zip file, however, I went ahead and basically did this instead which seemed to work:

git clone [email protected]:flyingmachine/emacs-for-clojure.git ~/.emacs.d

Does that make sense?

Appendix B: Malformed rake example

First example of Rake invocation in section Composition and Coordination is malformed. This probably happened because all code samples are treated as Clojure code by pygments.

Publish this as GitHub page?

It would be nice if you could publish this as a GitHub page, so one could directly read through the corrected version to search, find and report only those errors that still exist in this version.

I know that I found lots of errors on http://braveclojure.com/, but I would assume that many are already fixed in this repository. I don't want to waste anyone's time searching for errors that don't exist anymore.

And then there is also #82, which suggests that finding the errors on braveclojure.com in this repository might be very hard.

OT-question: Do you still plan to merge all the other PRs? It'd be a waste of everyone's time, if I created a big PR with all the errors I found and then you have to merge this and sort out any overlap with all the other PRs.

Typo'd "protocols" as "prototypes" in Chapter 13

In the Summary section of Chapter 13, the sentence:

In this chapter, you learned how to define your own abstractions using multimethods and prototypes.

should likely say protocols rather than prototypes.

Functional programming errata

Quick errata: println isn't the only non-pure function we've used. As I recall, previous chapters used rand and slurp. Cheers!

Chapter 5: valid-moves

Hi, Daniel!

Great book! A small correction. You write (p. 118 of the printed version)

Given this board, positions 1, 6, and 11 have valid moves, but all others don't.

This is not the case: when position 4 is open at the start of the game, position 13 has a valid move to position 4 by jumping over position 8. Your code is right as we can see by typing in the REPL.

pegthing.core> (def my-board (assoc-in (new-board 5) [4 :pegged] false))
#'pegthing.core/my-board
pegthing.core> (valid-moves my-board 13)
{4 8}

I am really enjoying the book and learning a lot! Thanks!

Unnecessary use of loop

I believe that this code in http://www.braveclojure.com/functional-programming/

(defn sum
  ([vals]
     (sum vals 0))
  ([vals accumulating-total]
     (loop [vals vals
            accumulating-total accumulating-total]
       (if (empty? vals)
         accumulating-total
         (recur (rest vals) (+ (first vals) accumulating-total))))))

...can be simplified to this (defn creates a recursion point, so you still get TCO even though you're not using loop):

(defn sum
  ([vals]
     (sum vals 0))
  ([vals accumulating-total]
     (if (empty? vals)
       accumulating-total
       (recur (rest vals) (+ (first vals) accumulating-total)))))

Cycling through history in repl

The following passage in the book doesn't work on my Mac. I'm not using any wierd configurations.

While still in nrepl, try C-↑, which is Control + the up key. C-↑ and C-↓ cycle through your nrepl history.

I can cycle through command history using M-p and M-n but using C-↑ and C-↓ leaves Emacs and causes my Mac OS to take over and go to the dashboard (same as if I did F3 which shows all open programs in the current window)

Chapter 5: Deep Mutual Recursion

In the chapter on Functional Programming, an example is made of mutually-recursive functions without a hard-set limit on recursion depth.

The example being a user-interactive game makes this reasonable. However, it may be interesting to mention to readers though that if one were to play again enough times (or have a script do it), because Clojure doesn't optimize away Mutual Tail Recursion, it will eventually blow the stack. Using the "trampoline" macro would prevent that.

"let*" and "render"

In chapter 8 ("Writing Macros"), you could include a few words on the meaning of "let*". Also, the function "render" is not properly introduced (and perhaps could even be replaced by "println" altogether).

Unable to resolve symbol `get`

On refer
https://github.com/flyingmachine/brave-clojure-web/blob/master/content/organization.md#refer-and-alias

the example when it uses get I get an error:

cheese-analysis=> (get (clojure.core/ns-map clojure.core/*ns*) 'bries)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: get in this context, compiling:(NO_SOURCE_PATH:1:1) 

Instead I had to do

cheese-analysis=> (clojure.core/get (clojure.core/ns-map clojure.core/*ns*) 'bries)
#'cheese.taxonomy/bries

Since I'm learning I might have done something wrong while typing into the Repl, if so, apologies and disregard my issue 😉

Thanks for such a great resource I love reading it on my tablet 😄

6.2. Double Evaluation, Wrong number of args (2) passed to report

The report macro takes only one argument, in the example we pass two:

(report (Thread/sleep 1000) (+ 1 1))

Possible fixes:

(report (do (Thread/sleep 1000) (+ 1 1)))

or change the macro (not sure this is the best way to do it):

(defmacro report
  [& to-try]
  `(if (do ~@to-try)
     (println (quote ~to-try) "was successful:" (do ~@to-try))
     (println (quote ~to-try) "was not successful:" (do ~@to-try))))

Chapter 2: split window for REPL

(Online version of the book)

When I do:

M-x cider-jack-in

I get a horizontally split frame, and from there I can't figure out how to get a vertically split frame. What I did figure out is that if I first do:

C-x 3

then I get a vertically split frame with clojure_noob/core.clj in both windows. Then if I do M-x cider-jack-in while the left window is selected, then a REPL will open in the right window--matching what the screen shots show.

Using Emacs with Clojure problems

Hello,

there are some problems with Using Emacs with Clojure chapter. Not sure where to report so if I'm wrong feel free to tell what is the right place for this issue.

Lein version:

Leiningen 2.5.0 on Java 1.8.0_40 Java HotSpot(TM) 64-Bit Server VM

I installed fresh Emacs 24.4 from here, moved my old emacs.d, and cloned one you provided. After doing M-x package-install and search for cider, cider-decompile is the first option. In order to install cider I used M-x package-list-packages, searched for cider and installed it.

After opening clojure-noob/src/clojure_noob/core.clj and running M-x cider-jack-in I get following error (copied from Messages):

Starting nREPL server via lein repl :headless...
You can run the command `cider-jack-in' with C-c M-j
Starting nREPL server via lein repl :headless...
nREPL server started on 51924
nREPL: Establishing direct connection to localhost:51924 ...
nREPL: Direct connection established
error in process filter: cider-repl-mode: Symbol's function definition is void: clojure-mode-variables
error in process filter: Symbol's function definition is void: clojure-mode-variables

There is no split window with repl, but I can see repl running in the buffer list.

So just a heads up that this is not working, and someone following tutorial might get stuck.

If I can help anyhow with this issue, feel free to contact me.

Cheers

Error in Code in Chapter 3

When loop is explained, there is the following code:

(defn recursive-printer
([]
(recursive-printer 0))
([iteration]
(println iteration)
(if (> iteration 3)
(println "Goodbye!")
(recursive-printer (inc iteration)))))
(recursive-printer)
; => Iteration 0
; => Iteration 1
; => Iteration 2
; => Iteration 3
; => Iteration 4
; => Goodbye!

This code is wrong, as the word "Iteration" is not printed. Just the numbers.

ansi, ansi-styles and colorize aren't defined in the web version

The three functions ansi, ansi-styles and colorize are mentioned and used in the code for Pegthing in the Functional Programming chapter (# 5) but aren't defined in the text—though they are there in the pegthing repo code.

It's a minor issue, of course—and thank you for the book!

nrepl.el is now CIDER

Just wanted to let you know that the nrepl.el project was recently renamed to CIDER.

Website updates from the repo

First, thanks for this book. Good job.

I'm reading it online at http://www.braveclojure.com and find some typos and suggestions. Then I want to give a bit back and throw my suggestions upstream, but the content on this repo is radically different at some places.

Why is it so?

Missing condition for ruby to closure example.

The guide provides this ruby example.

severity = :mild
error_message = "OH GOD! IT'S A DISASTER! WE'RE "
if severity == :mild
  error_message = error_message + "MILDLY INCONVENIENCED!"
elsif severity == :terrible
  error_message = error_message + "DOOOOOOOMED!"
end

Then states that the Clojure equivalent would be:

(def severity :mild)
(def error-message "OH GOD! IT'S A DISASTER! WE'RE ")
(if (= severity :mild)
  (def error-message (str error-message "MILDLY INCONVENIENCED!"))
  (def error-message (str error-message "DOOOOOOOMED!")))

However, the condition for elsif severity == :terrible is missing.
So shouldn't the correct Clojure equivalent be this?

(def severity :mild)
(def error-message "OH GOD! IT'S A DISASTER! WE'RE ")
(if (= severity :mild)
  (def error-message (str error-message "MILDLY INCONVENIENCED!"))
  (when (= severity :terrible)
    (def error-message (str error-message "DOOOOOOOMED!"))))

url: http://www.braveclojure.com/do-things/

Spacing around "—"

The spacing around "—" is often badly typeset. There are also several instances with additional spacing and a prolonged dash in inline code sections that should not be there. I.e. some --name or even some ---name instead of some-name (-- denoting the en dash, --- is again the em dash). Note the additional spacing in front of the dash as well as its prolonged nature (opposed to the intended short "-" minus).

Sometimes this just looks weird, but sometimes it is outright confusing (for example in the explanation of mapify in chapter 4 "Core Functions in Depth").

macro code-critic typo

pg. 175 in defmacro code-critic:

argument vector should be:

[bad good]

instead of:

[{:keys [good bad]}]

➊ and ➋ line markers cause bad indention

Sometimes the code is hard to understand, because the ➊ and ➋ line markers cause bad indention. Take for example the code after "Clojure lets you work around this apparent limitation with
recursion." in chapter 5 "Functional Programming".

String escape quotes in "Do Things" chapter of the book.

Hello. I've been following the book and something caught my eye. In the "Strings" part of the "Do Things (http://www.braveclojure.com/do-things/)" chapter of the book there's an example of string concat with str function. When entered into REPL (Clojure 1.8) used in Emacs, REPL doesn't return what the book suggests (; => "Uggllglglglglglglglll" - Chewbacca), but ; => "\"Uggllglglglglglglglll\" - Chewbacca", like it's not escaping the quotemarks. Is this a problem on my side?

Clarification on chapter 5

Hi Daniel,

After presenting the function can-move?, you wrote this:

Second, you use comp to compose this function with not-empty. This function is self-descriptive; it returns true if the given collection is empty and false otherwise.

But it seems that it is wrong, because from official Clojure's docs, the function not-empty return nil if the collection is empty, and collection otherwise.

For reference, this is the function that I am talking about:

(defn can-move?
  "Do any of the pegged positions have valid moves?"
  [board]
  (some (comp not-empty (partial valid-moves board))
        (map first (filter #(get (second %) :pegged) board))))

Also, I wanted to say thank you for writing this great book. I am really enjoying it and learning a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.