brave-clojure-web's People
Forkers
julianbonilla enikesha danlentz jwarwick mavlarn jokeofweek kpmaynard xsleonard nightkr apiology javaspock ilovejs zzl0 arronmabrey sleyzerzon armed apbendi catern marklundin halcyon therufs andrew-wharton jastix stianeikeland benjaminmitchell matthiasn jiangweiming laanak08 bangedorrunt mwfogleman esaul mihirk ssorc jerith tonyvanriet jean hardikus oemmerson gilhooley eleonore9 matthew-piziak emaphis cswaroop fellipebrito mikephys8 jrusev orther sarabander plexus jonathanchu pietromenna jsborjesson hristoyankov roxolan grahack airnsk rxfork mukhtar danielgerigk pragsmike paulkoegel bjornorri drewverlee maxbittker atdixon mloayzagahona kosii devurandom thelmuth dijonkitchen vakimov decadent tomerweller ylebedeva domspad rogererens dwightk lucasqiu styts kiwka josby teodorlu galactose imrekoszo archii crantok jeroenpelgrims plumpmath aliaksandr-s cambodiancoder khusnetdinov sanjeevkumar051996 hkopp kantuni hixio-mh jeff303 puchka fabriciobrave-clojure-web's Issues
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
ansi, ansi-styles and colorize aren't defined in the web version
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.
nrepl.el is now CIDER
Just wanted to let you know that the nrepl.el project was recently renamed to CIDER.
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!
hash-set example is sorted
It seems that in §
http://www.braveclojure.com/do-things/#2_8__Sets
for the example with :
(hash-set 1 1 3 1 2)
The clojure result is
; => #{1 3 2}
as we might expected and not
; => #{1 2 3}
as written in the document
Broken link for random word generator
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))))
➊ 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".
Broken link for Appendix A
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").
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.
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.
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?
Chapter 12: Broken link to clojure
The link in the java chapter is broken: It mixes up 1.7.0 and 1.9.0, and it doesn't use https. The link should be https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0/clojure-1.9.0.jar
Then the command after it should be updated (to point to 1.9.0) and the output of MANIFEST:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: jenkins
Build-Jdk: 1.7.0
Main-Class: clojure.main
"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).
writing macros if-valid typo
pg. 182 under if-valid:
Step 3 should read:
"If there weren't"
instead of
"If there were"
Bad markdown processing in To Catch a Burgler
See the actual page and search for The innermost loop takes a seq of keys
. It looks fine on GitHub, so I'm hesitant to just fix with a PR 😄 Something is wrong in the site generation.
Chapter 7: (read-string ("+"))
Extra parens around "+"
:
(read-string ("+"))
; => +
Instead, it should be:
(read-string "+")
; => +
Amazing chapter! And very useful tree images.
Small typo in "vampire?" method definition (page 85 in the pdf)
The captions of some of the listings ...
... are flawed. For example, the caption of Listing 9-3 is "1. enqueue’s implementation".
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!"))))
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?
Unable to resolve symbol `get`
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 😄
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)))))
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.
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!
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?
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.
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.
Core Functions in Depth - mention that lazy-seq is a macro
In Core Functions in Depth, you introduce lazy-seq
:
(defn even-numbers
([] (even-numbers 0))
([n] (cons n (lazy-seq (even-numbers (+ n 2))))))
It would help the understanding, if you mentioned, that it is a macro and thus does not follow regular evaluation semantics.
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!
macro code-critic typo
pg. 175 in defmacro code-critic
:
argument vector should be:
[bad good]
instead of:
[{:keys [good bad]}]
core.async Chapter Not Mentioned in 'TOC At A Glance' in home.md
I didn't fix it myself because it’s not just the link, it's the synopsis of the chapter below, which I imagine you'd want to write yourself.
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)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.