These are chat archives for ramda/ramda

2nd
May 2018
Lewis
@6ewis
May 02 2018 00:47 UTC
R.evolve -does it only work if we whitelist all the properties or can we just mention one and modify it
i was able to do the later
const transformation = {disable: !R.identity}
R.evolve(transformation, data[0]);
wont work
Brad Compton (he/him)
@Bradcomp
May 02 2018 01:34 UTC
@6ewis You'll want { disable: R.not } instead of !identity
Lewis
@6ewis
May 02 2018 11:39 UTC
@Bradcomp thanks. why is rthat
Rodrigo Juarez
@rodrijuarez
May 02 2018 12:01 UTC
hi, I need to do something like this:
export const functionThatTakesThreeParameters = cond([
    [equals("one"), functionThatTakesLastTwoParams1],
    [equals("two"), functionThatTakesLastTwoParams2],
    [equals("three"), functionThatTakesLastTwoParams3],
    [equals("four"), functionThatTakesLastTwoParams4]
]);
Lewis
@6ewis
May 02 2018 13:53 UTC
const turnDisableOn = R.when(
    R.equals(true, whiteListedBoxes["BoxUno"]), 
    R.assocPath(['disable'], true));
T is not a function
Lewis
@6ewis
May 02 2018 14:04 UTC
R equals does not curry like r.satisfied?
Lewis
@6ewis
May 02 2018 14:37 UTC
is there a r.assoc for many fields at once
Alec
@alavkx
May 02 2018 14:44 UTC
@6ewis
R.identity = x => x
R.not = x => !x
!R.identity ~= coercing identity function to a boolean, instead of the output of identity function
Alec
@alavkx
May 02 2018 14:57 UTC

R equals does not curry like r.satisfied?

It does, but R.equals only takes two arguments. R.when expects a predicate function, not a boolean value. So by providing both arguments to R.equals you are passing a value to R.when instead of the required predicate function.

I think what you want here is something like

const turnDisableOn = x => whiteListedBoxes["BoxUno"] ? { ...x, disable: true }: x;
Lewis
@6ewis
May 02 2018 14:58 UTC
thanks @alavkx
what about updating assoc values at once
Alec
@alavkx
May 02 2018 14:59 UTC
There is R.pick and R.omit, which might work depending on your use case
Lewis
@6ewis
May 02 2018 15:00 UTC
R.assocPath('c', 'c', object) ===> for many values instead of one
Alec
@alavkx
May 02 2018 15:02 UTC
That one I think you'll have to hand roll, not aware of any functions in the API that can do that. Double check though, I'm no ramda master :)
in the api you can filter by function type, so type "object" in to the search and you'll get all functions that operate on objects
Lewis
@6ewis
May 02 2018 15:03 UTC
thanks bud
Alec
@alavkx
May 02 2018 15:03 UTC
No problem man GL
Miguel Dorta
@ellipticaldoor
May 02 2018 19:54 UTC
Hi
Im trying to rewrite this function using ramda
export const tilesIterator = (cols, rows, method) => {
    range(0, cols).map(col => {
        range(0, rows).map(row => method(col, row))
    })
}
To something like this
export const tilesIterator = (cols, rows, method) => {
    map(map(method(col, row), range(0, rows)), range(0, cols))
}
The problem is that now I can't obtain col and row
Miguel Dorta
@ellipticaldoor
May 02 2018 20:07 UTC
Just found how
map(col => map(row => method(col, row), range(0, cols)), range(0, rows))
Brad Compton (he/him)
@Bradcomp
May 02 2018 22:51 UTC
@ellipticaldoor You can also use R.xprod to generate your pairs
(cols, rows, method) => map(apply(method), xprod(range(0, rows), range(0, cols)))
@ram-bot
const method = (x, y) => `(${x}, ${y})`;

const applyToGrid = (cols, rows, method) => 
    map(apply(method), xprod(range(0, rows), range(0, cols)))

applyToGrid(4, 4, method);
hmm