On Sunday, April 9, 2017 at 9:44:00 PM UTC-5, Alexander Gunnarson wrote: > > > As an aside about the stateful `take` transducer, Tesser uses the > equivalent of one but skirts the issue by not guaranteeing that the first n > items of the collection will be returned, but rather, n items of the > collection in no particular order and starting at no particular index. This > is achievable without Tesser by simply replacing the `volatile` in the > `core/take` transducer with an `atom` and using it with `fold`. But yes, > `take`'s contract is broken with this and so still follows the rule of > thumb you established that `fold` can't use stateful transducers (at least, > not without weird things like reordering of the indices in `map-indexed` > and so on). >
Right, we intentionally chose to require transducer takes to occur in order to match the sequence take. Tesser's approach is perfectly fine too (as long as you understand the difference). > That's interesting that `fold` can use transducers directly! I haven't > tried that yet — I've just been wrapping them in an `r/folder`. > Oh, you still need r/folder, sorry! Something like: (r/fold + (r/folder v (map inc))) -- 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.