I think this is one of those cases where I need to see an example to understand.
>From what I can tell, the `(fn [f1] (rfn ...))` argument to `folder` is a reducing-function-transformer--i.e. transducer, except there are some differences in things like order of application in composition. I *don't* see this 3-arity case for the transducer version of `clojure.core/map`. In my mind, the following are equivalent (r/reducer [1 2 3] (map f)) (r/map f [1 2 3]) So the following should be equivalent: ;; Reducer (fn [f1] (rfn [f1 k] ([ret k v] (f1 ret (f k v))))) ;; macroexpands to (fn [f1] (fn ([] (f1)) ([ret v] (f1 ret (f v))) ([ret k v] (f1 ret (f k v))))) ;; and should be equivalent to the transducer (map f): (fn [rf] (fn ([] (rf)) ([result] (rf result)) ([result input] (rf result (f input))) ([result input & inputs] (rf result (apply f input inputs))))) Yet they are clearly *not* the same: there is nothing in the transducer about `[ret k v]`. So I must be missing something fundamental about the relationship between reducers and transducers. On Thursday, May 18, 2017 at 9:34:54 PM UTC-7, Alex Miller wrote: > > Reducers combine functionally, so they all have to support it to create > any composite reducer that contains map. > > On Thursday, May 18, 2017 at 10:11:23 PM UTC-5, Tianxiang Xiong wrote: >> >> Would that ever be the case for `r/map`? Or does it only apply to certain >> other reducers? >> >> On Thursday, May 18, 2017 at 4:11:39 PM UTC-7, Alex Miller wrote: >>> >>> The 3 arity is used when reducing over a map, like reduce-kv. Reducers >>> do this automatically which varies from the core reduce. >> >> -- 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.