(reduce (fn [x y] (+ x y)) [1])
=> 1Typically, when calling reduce we pass in a 2-arity function, like so:
(reduce (fn [x y] (+ x y)) numbers)
However, if numbers has zero arguments in it, reduce will invoke our
function with zero arguments. If numbers has one argument in it, reduce
will invoke our function with just the first element. In both cases, this will
throw an exception.
--
You received this message because you are subscribed to the Google Groups "Elements of Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elements-of-clo...@googlegroups.com.
To post to this group, send email to elements-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elements-of-clojure/f47b77c2-dc3c-436e-870a-252b8cb75159%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.