This is not safe usage, as you are not calling the 'flushing' method
or handle reduced objects. Correct use would be
(def xform (comp (filter odd?) (map #(* % %))))
(def strip-reduced [x] (if (reduced? x) @x x))
(let [r (xform conj)] (strip-reduced (r (strip-reduced (r #{1 2 3}
7))))) ;=> #{1 3 2 49}
(let [r (xform conj)] (strip-reduced (r (strip-reduced (r [1 2 3]
6))))) ;=> [1 2 3]
Even then, you should not pass any function into xform, but only a
function which has 0, 1 and 2 arg arities implemeneted at least.
Jozef
On Thu, Aug 14, 2014 at 12:00 PM, <[email protected]> wrote:
> 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 [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.