Welcome! Please see the About page for a little more info on how this works.

0 votes
in Docs by

The docstring for reduce includes this: "If val is not supplied, returns the result of applying f to the first 2 items in coll". This is true if coll is a sequence, but not if it is a reducer. For example:

user=> (->> (range 0 10 2) (reduce (fn[x y] (+ x y)))) 20 user=> (->> (range 0 10 2) (r/map #(/ % 2)) (reduce (fn[x y] (+ x y)))) ArityException Wrong number of args (0)

The docstring should be updated to make it clear that reducers (used without an initial seed value) require the reducing function to support a 0 arity overload returning the identity value for the reduction operation.

1 Answer

0 votes
Reference: https://clojure.atlassian.net/browse/CLJ-1443 (reported by glchapman)