Fork me on GitHub
#clojure-dev
<
2022-04-05
>
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)

ghadi15:04:59

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

ghadi15:04:13

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

ghadi15:04:47

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

😭 1