These are chat archives for ramda/ramda
var lessthan3 = gt(3)
gt(3,4) == false // 3>4
new Promise(() => 1).then( num => num + 2).then(console.log)==
pipe(identitiy, add(2), console.log)
compose(f, g, h)(v) === f(g(h(v))
why are the arguments there? performance? having .length? any comments about it somewhere to read?
function.lengthto be correct.
I am trying to create a 'filterAccum' method, which is going to work exactly like 'filter', expect it will have an accumulator method to transform the data during each iteration, before using a filter on the modified data.
My problem is I have to make an exception (see the 'if' line in my code) to handle an array of numbers instead an array of string, because I am using mapAccum behind the scene, and the "acc" parameter of "mapAccum" should be 0 by default when operating on numbers, but  when operating on anything else.
How can I improve this code to avoid making this exception ? (maybe using something else than mapAccum)
@JulienBonnin-ABTasty To elaborate on what @xgrommx said, something like:
const filterAccum = curry( (p, fn, acc, list) => reduce((a, v) => p(v) ? fn(a, v) : a, acc, list) )
That would allow you to:
filterAccum(n => n % 2 === 1, (...n) => R.sum(n), 0, [5, 10, 15]) // 20 const strings = filterAccum(n => n.length % 2 === 1, (a, b) => a + b, '') strings(['aweso', 'me!', 'cannot see this!'])