These are chat archives for ramda/ramda

21st
Jun 2018
Matt McKellar-Spence
@MattMS
Jun 21 2018 04:39
@lieberkind the Ramda docs are built using npm scripts. It should be documented in the readme at https://github.com/ramda/ramda.github.io/ (as @Bradcomp mentioned). The pages were originally Moustache templates, but these were difficult to do inheritance in, so they have been switched to Pug (although there may be some of the old templates/scripts lurking in there). Please feel free to ping me if you have any questions on it. :smile:
lukasbash
@lukasbash
Jun 21 2018 09:43
@ben-eb @Bradcomp absolutely beautiful answers! i will take a look at both approaches! thank you guys!
Nik
@niksosf
Jun 21 2018 10:17
@lukasbash
@lukasbash you can also use transducers if your collection is large.
``````import { compose, map, filter, takeWhile, seq } from 'transducers.js';
const xs = [1,2,3,4, 5, 6,7]
const transformation = compose(
map(x => (console.log("--> calling for", x), x * 2)),
filter(x => x%3 !==0),
map(x => (console.log("exponentiation"), x**2))
)
const output = seq(xs, transformation)``````
``````--> calling for
1
exponentiation
--> calling for
2
exponentiation
--> calling for
3
--> calling for
4
exponentiation
--> calling for
5
exponentiation
--> calling for
6
--> calling for
7
exponentiation
[9, 25, 81, 121, 225]``````
the `filter` will short circuit the computation as can be seen for cases `3` and `6` in the collection.
lukasbash
@lukasbash
Jun 21 2018 12:18
@niksosf isnt this similar to the transduce implementation of ramda itself? whats the difference actually?
Nik
@niksosf
Jun 21 2018 13:10
@lukasbash
Right there isn't :) i just like to use the `seq` function
``````import { into, compose, map, filter, pipe } from 'ramda';
const xs = [1, 2, 3, 4, 5, 6, 7]
const transformation = compose(
map(x => (console.log("--> calling for", x), x * 2)),
filter(x => x % 3 !== 0),
map(x => (console.log("addition"), x + 1)),
map(x => (console.log("exponentiation"), x ** 2))
)

const output = into([], transformation, xs)
console.log(output)
--> calling for
1
exponentiation
--> calling for
2
exponentiation
--> calling for
3
--> calling for
4
exponentiation
--> calling for
5
Did you mean the actual difference between the different implementation of transduce between `ramda` and `transducers.js` or transducers vs a normal function composition?