DEV Community

Discussion on: Transduction in JavaScript

Collapse
 
jmaicaaan profile image
JM Santos

I'm honestly still having a hard time wrapping my brain when it comes to this. I mean, it's easy to understand normal compose and pipe flow of data. But, it's challenging for me to 100% track the flow of reducers in the transducers.
Thanks for the example. Took me a lot of reread :)

Collapse
 
iquardt profile image
Iven Marquardt

Ya, it's hard stuff. If we dig even deeper the reason for all this confusing behavior is the composition itself. comp doesn't return a value, but another composed function. I think you already mentioned this in your post. This is sometimes called abstraction over arity, because this new composed function expects more arguments than comp = (f, g) => x => f(g(x)) has originally required. Whenever this happens, the order of evaluation switches to left-to-right, not only with transducers.