These are chat archives for ramda/ramda

13th
Feb 2018
Ivanov Ivan
@832bb9
Feb 13 2018 09:08
Hi all
Can someone help me with this issue?
const zipLongest = R.pipe(
  R.unapply(R.identity),
  R.juxt([
    R.flip(R.pluck), // don't work
    // R.pipe(R.identity, R.flip(R.pluck)), // work
    // R.curryN(1)(R.flip(R.pluck)), // work
    R.pipe(R.map(R.length), R.apply(Math.max), R.range(0))
  ]),
  R.apply(R.map),
);
Ivanov Ivan
@832bb9
Feb 13 2018 09:23
Here is example of how it works:
zipLongest([1], [10, 20], [100, 200, 300]) // -> [[1,10,100], [undefined,20,200], [undefined,undefined,300]]
Ivanov Ivan
@832bb9
Feb 13 2018 10:39
I found the problem. Juxt uses converge under the hood, and converge curried to max arguments length of its functions. So R.pluck waits for 2 arguments, and juxt curried to 2 arguments. But its not obviously, because i want R.pluck to get one argument and return function, that i use in R.map.
So, i think, its the best solution in this case:
const zipLongest = R.pipe(
  R.unapply(R.identity),
  R.juxt([
    R.curryN(1)(R.flip(R.pluck)),
    R.pipe(R.map(R.length), R.apply(Math.max), R.range(0))
  ]),
  R.apply(R.map),
);
Jason Shin
@JasonShin
Feb 13 2018 11:01
guys
is it possible to enable errors in Ramda?
instead of gracefully failing
I want to see errors lol
Tomáš Konrády
@tommmyy
Feb 13 2018 13:26
@JasonShin you can't see any error? thats strange.. in my project I see them
Rocky Madden
@rockymadden
Feb 13 2018 15:03
What do you mean by gracefully failing?
Bijoy Thomas
@bijoythomas
Feb 13 2018 15:21

@zhtbcgtw you can also use ap to get the flip(pluck) to behave the way that you want (getting one argument, and the next argument with the map)

const zipLongest = R.pipe(
  R.unapply(R.identity),
  R.of,
  R.ap([
    R.flip(R.pluck),
    R.pipe(R.map(R.length), R.apply(Math.max), R.range(0))
  ]),
  R.apply(R.map)
)

but it requires boxing the arguments in another array so that the ap works as desired

Denis Stoyanov
@xgrommx
Feb 13 2018 20:14
zipLongest?