These are chat archives for ramda/ramda

Apr 2018
Pedr Browne
Apr 07 2018 11:26

I have a nested list:

const list = [
  ['a', ['alpha'],
  ['b', ['bravo'],
  ['a', ['charlie'],
  ['c', ['echo'],
  ['a', ['foxtrot'],
  ['b', ['gamma'],

I need to combine items with identical values for the first item to result in this:

const mergedList = [
  ['a', ['alpha', 'charlie', 'foxtrot']],
  ['b', ['bravo', 'gamma']],
  ['c', ['echo'],

I can guarantee that each list will only contain two items, and that the second item will be a shallow array. I can't convert to object as order is critical.

Denis Stoyanov
Apr 07 2018 11:42
@Undistraction hm, smth like compose(toPairs, reduce(mergeWith(concat), []), map(apply(objOf)))(list)
Pedr Browne
Apr 07 2018 11:55
@xgrommx Thanks. That looks good, but don't think order is guaranteed due to use of objOf (See last line of my question).