Re:Map/Reduce for Mortals
by crooked-v on Tuesday January 14, 2020 @03:18PM
(#22048832)
That's also basically the same syntax as doing it in JS, aside from the lack of builtins:
Or, if you're using the pipeline operator (experimental, stage 1, nobody can quite decide on exactly the syntax but this gives the rough idea):
[ Parent
| on HN ]
We can get rid of these arrows using ramda's curried list functions, at the expense of being slower and harder to read but making us feel more clever:
pipe(
range,
filter(pipe(
modulo(__, 3), // x => x % 3
equals(1) // y => y === 1
)),
map(flip(Math.pow)(2)),
sum
)(1,6)