These are chat archives for ramda/ramda

21st
Jan 2018
Francisco
@franciscotln
Jan 21 2018 01:01
kinda strange, it doesn't behave like the native reduceRight :-(
const arr = [ [0, 1], [2, 3], [4, 5] ];

R.reduce((a, b) => a.concat(b), [], arr); // [0, 1, 2, 3, 4, 5]
R.reduceRight((a, b) => a.concat(b), [], arr); // [0, 1, 2, 3, 4, 5]

arr.reduce((a, b) => a.concat(b), []); // [0, 1, 2, 3, 4, 5]
arr.reduceRight((a, b) => a.concat(b), []); // [4, 5, 2, 3, 0, 1]
Simon Friis Vindum
@paldepind
Jan 21 2018 11:37
Does anyone know of a tool where I can type in a JS expression with a "hole" in it and an expected result and then the tool will find a function that gives the expected result? So for instance I could type R.map(?, [1,2,3); //=> 6 and the tool would tell me that R.add would work as ?? That would be super useful as a way of searching for functions.
As another example I may want to type ?("a", "bcd"); //=> "abcd" and the tool would tell me to use R.concat.
Denis Stoyanov
@xgrommx
Jan 21 2018 15:46
I think js isn't good language for this inference
Simon Friis Vindum
@paldepind
Jan 21 2018 15:57
@xgrommx What do you mean?
Thomas Kempel
@thomaskempel
Jan 21 2018 19:03
@franciscotln the difference is that the callbacks parameters are the other way around. Ramda (a=accumulator,b=currentValue) and native is (a=currentValue,b=accumulator)
see this repl example with logs ramda repl
and see docs of reduceRight (ramda): "The iterator function receives two values: (value, acc), while the arguments' order of reduce's iterator function is (acc, value)."
Mike Lambert
@lax4mike
Jan 21 2018 19:47
But, why are the arguments the swapped?