I'm solving Problem 22 from the 4Clojure site asking me to write a function that counts the elements in a sequence. Because I messed around with Haskell at one point, I know that using fold
is probably the way to go about doing that. After reading about it, I've come to the understanding that I should be using reduce
for the same purpose. Here's the answer I submitted:
#(reduce inc 0 %)
The reasoning behind this is to iterate the list, and call inc
each time on the value which is initially 0. However, this does not work. The site is complaining that the "Wrong number of args (2) passed to: core$inc". So I tried adding parens around inc
:
#(reduce (inc) 0 %)
Now it thinks zero arguments are being passed to inc
. What am I doing wrong here?