I’m a Clojure newbie. I’m trying to understand why the second form doesn’t work:
First form:
user=>(def nums(range 3))
(0 1 2)
user=>(map #(list %1) nums)
((0) (1) (2))
Second form:
user=> (map #(list %1) (0 1 2))
java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
(NO_SOURCE_FILE:0)
The problem is the expression
(0 1 2), which is interpreted as0applied to1and2; that’s impossible because0isn’t a function.works as intended, though.