I am writing a custom transducer as an exercise, but I am surprised to see that its 0-arity init function is not called.
Why?
Is it related to which aggregation function I am using? If yes, which ones would call the init function and why others are not?
(defn inc-xf [xf]
"inc-xf should be equivalent to (map inc)"
(fn
;; init
([]
(println "init") ;; <- this is not called (???)
(xf))
;; step
([result input]
(println "step" result input)
(xf result (inc input)))
;; completion
([result]
(println "completion" result)
(xf result))))
(transduce inc-xf
+
100
[5 5 5])