Situation: Emacs, cider 0.9, writing some Clojure code. Like this:
1 2 3 |
x (map #(* radius (cos %1) (sin %2)) radian-s radian-t) y (map #(* radius (sin %1) (sin %2)) radian-s radian-t) z (map #(* radius (cos %) radian-t)) |
See the error? These three lines are part of a short program for producing graphics with Quil. Suppose radian-s and radian-t are seqences of numbers. The compiler swallowed it with without groaning, I ran the code and got an empty window. After checking and re-checking again I went through Emacs’ buffers and found a lot of error messages in nrepl-server:
Exception in :draw function: #
stacktrace: clojure.lang.ArityException: Wrong number of args (1) passed to: core/map
at clojure.lang.AFn.throwArity (AFn.java:429)
What? Why was this error coming up only at run-time and not when compiling? And which line didn’t work exactly? Short answer: it’s the last one which should look like this:
1 |
z (map #(* radius (cos %)) radian-t) |
No idea why the wrong version slipped through, but it’s always a good idea to check the balance of parentheses, anyway. And to have a look at nrepl-server’s output. Certainly nothing new for Clojure experts, but noobs like me might learn from it.