12 points · by jacquesm · 17y ago · 20 comments
Edit: There are other style problems with this article. Worst is probably this one:
Bad: (map (fn [x] (fibonacci x)) [1 2 3 5 6 7 8 9 10])
Good: (map fibonacci (range 1 11))The way your parens should flow:
(def factorial
(fn [n]
(loop [cnt n acc 1]
(if (zero? cnt)
acc
(recur (dec cnt) (* acc cnt))))))
The author doesn't take an idiomatic approach to programming in Clojure in most of his code snippets.[edit]
Throwing java.lang.Exception if a condition is not meat in your clojure functions? Don't do this either!!!
What's the proper way of doing that in clojure ?
You can also define your own specific (app-level) exception by proxying the RuntimeException or other relevant using the clojure's proxy macro.
My 'C' parser keeps telling me 'wrong bracket' though :)