2

When Rich introduced transducer in clojure, the concept is base on an assumption that map can be implemented via reduce. But how we can implement (map + [1 2] [1 2]) via reduce if reduce don't accept multiple collections?

To achieve this the current reduce api need to be enhanced?

Shark
  • 93
  • 5
  • 1
    on a conceptual level it's not necessary - just *zip* the lists into a tuples and *lift* the operation to work component-wise on those tuples - afterwards *unzip* (if you like) – Random Dev Apr 11 '16 at 11:20
  • @Carsten Yes, but in clojure, we still need to use map to zip it right? So map still cannot be implemented by reduce right? – Shark Apr 14 '16 at 08:23
  • I have trouble understanding your comment - it's `zip` you cannot implement using `reduce` (you can use the *dual* of reduce though) - don't get me wrong but this is just an example of where clojures/lips way of *powerful* functions (aka functions that do way more than one thing - for example mapping on more than one list) obfuscates the concepts - so yes you have difficulties of doing this here - btw: another way would be `map (map (+))` (sorry don't know the correct way to encode this in clojure ... don't even know if there is one) - *map the map* ;) – Random Dev Apr 14 '16 at 09:05

0 Answers0