Eduction retains the ability to be recomposed with other transducers higher
in the function chain. The following two are nearly equivalent:
(transduce (take 1e2) + (eduction (filter odd?) (range)))
(transduce (comp (filter odd?) (take 1e2)) + (range))
This will be slower:
(transduce (take 1e2) +
Hello, what is the reason for comp to produce two different orderings
depending on whether it composes partials or transducers?
(comp (partial filter even?) (partial map (partial + 1)))
(comp (filter even?) (map (partial + 1)))
Wouldn't it be more intuitive for upcoming clojurians to have both
Some alternate transducers usage:
(def xform (comp (filter odd?) (map #(* % %
((xform conj) #{1 2 3} 7) ;=> #{1 3 2 49}
((xform conj) [1 2 3] 6) ;=> [1 2 3]
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo
(let [data [1 3 4 5 7 9 10 11 12]
seen (atom (first data))]
(partition-by #(if (< (- % @seen) 2)
(do (reset! seen %) true)
(do (reset! seen %) false))
data))
((1) (3 4 5) (7) (9 10 11 12))
On Thursday, November 6, 2014 11:22:14 PM UTC+
I find these examples very memorable. Despite the doc strings clearly
stating the differences between transduce and reduce, one can still hastily
assume that transducing [0 1 2] will have 0 as the init argument.
I will add that the culprit is in defining the +ten's arguments with [&
args] form,