hope this makes sense. I had a list of objects like this:
const xs = [
{ foo: 2, bar: 2, baz: 3 },
{ qux: 1, bar: 0.5 },
{ foo: 3, bar: 2, qux: 4 },
]
that I wanted to turn into a single object, by passing a function to merge similar keys/values.
Not every key is present in every object.
I can't use mergeAll(xs)
because that would just overwrite values; what I want to do here is supply a function for how they should be combined.
The example in the documentation block ^^^ shows how I'm initially using it - with add
(but it could be used with any function)
It seems like this is still overly complicated - two things I'm thinking:
zipWith
does almost exactly what I want to do, but it works on lists rather than objects- there might be trickier Ramda concepts that I'm missing out on. I still don't understand
lift
, for example. Am I missing something?