Tentative benchmark results have surfaced: https://github.com/thheller/transduce-bench
Add salt according to taste.
Add salt according to taste.
(comp (map inc) (filter even?)) means filtering first, then incrementing.
The opposite for (->> data (map inc) (filter even?) ...
- which is not the same. And of course, it also means that the latter has to increment the double amount of numbers.
EDIT: It was me who was wrong, thanks for the corrections. Pitfall successfully identified :)
(sequence (comp (map inc) (filter even?)) (range 10))
;;=> (2 4 6 8 10)
(->> (range 10) (map inc) (filter even?))
;;=> (2 4 6 8 10)
Both test functions in transduce-bench return 250000500000.