Skip to content
Advertisement

ramda transducers with final R.sum

I’m trying to understand Ramda’s transducers. Here’s a slightly modified example from the docs:

JavaScript

But what if I want to sum the elements of the resulting array? The following (just adding R.sum into R.compose) doesn’t work:

JavaScript

Advertisement

Answer

I’d do something like this, just accumulate on top of an initial 0 value

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement