Fork me on GitHub
Ben Sless15:04:46

Is this a bug?

(#'clojure.core.protocols/iter-reduce [1 2 3] conj)
Execution error (ClassCastException) at user/eval10101 (REPL:1).
class java.lang.Long cannot be cast to class clojure.lang.IPersistentCollection (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.IPersistentCollection is in unnamed module of loader 'app')

Ben Sless15:04:24

iter-reduce binds the first value of ret to be the first element from the iterator and not (f)


not a bug. The init-less reduce arity (which is awful, don't call it!) is documented to call the reducing function on the first two elements of the collection


If val is not supplied,
  returns the result of applying f to the first 2 items in coll
(docstring of reduce)


transduce and clojure.core.reducers/reduce operate differently.

😭 1