These are chat archives for ramda/ramda

23rd
Mar 2018
Kurt Milam
@kurtmilam
Mar 23 2018 08:54
@artivilla transactions won't be mutated given your example code. It's not really clear to me what you're trying to accomplish with that function.
sitty
@sitty
Mar 23 2018 14:32
How can I rewrite the following function more functionally
let fixMetadata = o => {
                        var t = omit(['column_order', 'index_column'], o)

                        t.Order = parseInt(o.column_order)
                        t.IsIndex = parseInt(o.IsIndex)
                        return t
                    }
Mike Lambert
@lax4mike
Mar 23 2018 14:33
try using R.compose to combine R.omit with R.evolve
or maybe R.assoc instead of R.evolve
sitty
@sitty
Mar 23 2018 14:36
@lax4mike Does R.evolve adding new properties?
Maciej Maciaszek
@memee
Mar 23 2018 15:06
Hi, I'm looking for a func definition that will sum up all total key in [{ total: 1}, {total: 3}, ...]
Mike Lambert
@lax4mike
Mar 23 2018 15:07
@sitty i don't think it will, but R.assoc will
@memee try R.composeing together R.prop and R.sum
Maciej Maciaszek
@memee
Mar 23 2018 15:09
Ok, great I'll try
Thanks @lax4mike In the beginning I was thinking of R.reduce with R.add. Let's try your suggestion
Mike Lambert
@lax4mike
Mar 23 2018 15:10
well, R.sum can be defined in terms of R.reduce and R.add
Maciej Maciaszek
@memee
Mar 23 2018 15:11
Sth like R.reduce(R.add, 0)?
Mike Lambert
@lax4mike
Mar 23 2018 15:11
@ram-bot
const sum = R.reduce(R.add, 0);
sum([1, 2, 3]);
ram-bot
@ram-bot
Mar 23 2018 15:11
6
Maciej Maciaszek
@memee
Mar 23 2018 15:13
but some mapping is needed

@ram-bot
const total = [
{ total: 1},
{ total: 2}
];

R.compose(R.sum, R.map(R.prop('total')))(total)

Mike Lambert
@lax4mike
Mar 23 2018 15:16
// 3 :thumbsup: