These are chat archives for ramda/ramda

Dec 2017
Mike Lambert
Dec 12 2017 03:14
Looks good, you can also make it a function like this
const getFrameIndexFromName = (frameName) => R.findIndex(R.propEq("wallpos", frameName), FDWD.Frames);
const result2 = getFrameIndexFromName("someName");
Matías Fidemraizer
Dec 12 2017 14:22

hey! I understand that there's no out-of-the-box function like splitEvery which outputs arrays even when the input array has less element than the argument provided to splitEvery.

For example: splitEvery(5, [1]). I need to get [[1]] anyway

nvm... it already does, now I need to check why in my code I don't get what I want,
Dec 12 2017 14:29

Hello functional aficionados. I make regular use of the following to functions to perform insert or update operations on collections:

const ifFoundElse = (predicate, onFound, onNotFound) =>
    R.find(predicate),, onFound)),

const mergeOrAppend = (predicate, object) => ifFoundElse(predicate, R.merge(R.__, object), R.append(object))

This works pretty well and I've naively used this maintain an ordered collection by performing a resort after every mergeOrAppend. I can't help thinking that this approach could be vastly improved both in terms of elegance and performance by making use of the knowledge that the collection is sorted and being able to do some sort of 'insert at' rather than an append followed by a sort.

I'm struggling to find the right tools for the job in the ramda toolbox. Can someone point me in the right direction?

Mike Lambert
Dec 12 2017 19:02
where are you doing the sort?
maybe you just need to make a function insertIntoSorted or something and use that instead of R.append