|
|
|
|
|
by ds300
4006 days ago
|
|
> (reduce (map inc) [1 2]) ;; same as (map inc [1 2]) This is wrong. You've missed the point. (map inc [1 2])
is actually roughly equivalent to (reduce ((map inc) conj) [] [1 2])
which, due to the use of `reduce`, is eager. To get laziness back: (sequence (map inc) [1 2])
Transducers are not reducing functions, they return reducing functions when applied to reducing functions. `((map inc) conj)` is a version of `conj` that calls `inc` on all the rhs args before `conj`ing them into the lhs arg. |
|