These are chat archives for ramda/ramda

19th
Sep 2018
Johnny Hauser
@m59peacemaker
Sep 19 2018 02:03
It's been a while since I have used Ramda - I used to use R.over a lot to transform an object property with a function, but I think I remember finding out there's a more direct way to do that, but I can't find it now.
Brad Compton (he/him)
@Bradcomp
Sep 19 2018 02:04
Evolve?
Johnny Hauser
@m59peacemaker
Sep 19 2018 02:04
R.something('foo', R.inc, { foo: 1 }) // => { foo: 2 }
@ram-bot
R.evolve({ foo: R.inc }, { foo: 1 })
@Bradcomp probably so, thanks!
Did ram-bot die or did I forget how to use it?
Brad Compton (he/him)
@Bradcomp
Sep 19 2018 02:08
Yeah it hasn’t been working lately
Narley Brittes
@narley
Sep 19 2018 07:19

Hey folks. I have this structure: [ {a: 'x', b: 5}, {a: 'x', b:10}] and the final result should be: ['x',15].
'a' will always be the same in both arrays.
I came up with the following approach but feels too clumsy:

const xs = [ {a: 'x', b: 5}, {a: 'x', b:10}] // => ['x',15]

R.compose(
  R.map(
    R.ifElse(
      pair => R.equals(NaN, R.sum(pair)),
      R.head,
      R.sum
    )
  ),
  R.transpose,
  R.drop(2),
  R.converge(
    R.concat,
    [R.map(R.keys), R.map(R.values)]
  )
)(xs)

any better solution? Cheers!

Adam Szaraniec
@mimol91
Sep 19 2018 12:25
const mergFn= (a, b) => R.is(Number, a) ? a + b :a;
R.values(R.mergeWith(mergFn,...xs));
Pedro Ávila
@avilapedro
Sep 19 2018 13:12
Ramda REPL is not working.
Pedro Ávila
@avilapedro
Sep 19 2018 13:20
Hmm, strange behavior, it's working in Opera, but not in Firefox.
Pedro Ávila
@avilapedro
Sep 19 2018 13:34
It is working on both now, looks like it was a problem with https://cdn.jsdelivr.net/npm/ramda@latest/dist/ramda.min.js