3 ms·
That's also basically the same syntax as doing it in JS, aside from the lack of builtins: import { range } from 'ramda'; range(1, 6) .filter(i =
by crooked-v 7y ago
That's also basically the same syntax as doing it in JS, aside from the lack of builtins:
import { range } from 'ramda';
range(1, 6)
.filter(i => i % 3 === 1)
.map(i => i * i)
.reduce((a, b) => a + b, 0);
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):
import { range, sum } from 'ramda';
range(1, 6)
|> x => x.filter(i => i % 3 === 1)
|> x => x.map(i => i * i)
|> sum
- 1-more 7y agoWe 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)