Once a transducer is completed it should never be called again. This is why transduce takes both a transducer and a reducing function and combines them internally. The thought here is that it will be harder to shoot yourself in the foot by reusing a stateful reducing function if you don't have to combine the xf with the rf manually.
Timothy On Sat, Jul 22, 2017 at 9:33 AM, David Bürgin <dbuer...@gluet.ch> wrote: > Hello all, > > I found an edge case where stateful transducers in core differ in > whether they reset or clear state in the completion arity > (partition-all) or don’t (take). > > Given the two transformed reducing functions > > (def conj-partitioning-all-3 ((partition-all 3) conj)) > (def conj-taking-3 ((take 3) conj)) > > when performing transduction with those reducing functions twice in a > row, one yields the same result twice, the other doesn’t. > > (transduce identity conj-partitioning-all-3 [] (range 10)) > ;; => [[0 1 2] [3 4 5] [6 7 8] [9]] > ;; => [[0 1 2] [3 4 5] [6 7 8] [9]] > > (transduce identity conj-taking-3 [] (range 10)) > ;; => [0 1 2] > ;; => [] > > Question: which behaviour is the one I should emulate in my own > transducers? > > Thank you, > David > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > 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 clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.