4 ms·
Genuine question: what is the point of this? it seems like a long-winded and not very clear way to write something you could just do with a function and a list
by anentropic 11y ago
Genuine question: what is the point of this?
it seems like a long-winded and not very clear way to write something you could just do with a function and a list comprehension
- moomin 11y agoWell, in Clojure they solve the problem that the standard functions are inefficient when you chain a bunch of list manipulations together (because they all return lazy lists) and neatly sidestep the fact that Clojure doesn't have generators.
- ch 11y agoSo if Clojure had some form of fusion of composed functions on lists, that would equate out to what transducers are doing?
- fnordsensei 11y agoThat's almost literally what happens. (comp (map inc) (filter even?)) when applied takes all even numbers from a collection/channel/what-have-you and adds one to them. Filter and map normally take a collection as their last argument, but when none are supplied, a transducer is returned instead.