These are chat archives for ramda/ramda

19th
May 2017
Jordy Vialoux
@JordyVialoux
May 19 2017 12:40
Tushar Mathur
@tusharmath
May 19 2017 12:40
@JordyVialoux R.assocPath
Jordy Vialoux
@JordyVialoux
May 19 2017 12:41
@tusharmath sorry mate I don't quite understand?
Tushar Mathur
@tusharmath
May 19 2017 12:42
R.assoc(['carousel', 'expand'],  true , state)
this would work for your case right ?
i think u wanted to update a nested property, correct?
Jordy Vialoux
@JordyVialoux
May 19 2017 12:43
that's correct
unfortunately that didn't work, it created a new property within my state
carousel,expand(pin): true
Tushar Mathur
@tusharmath
May 19 2017 12:44
oh u want to toggle ?
Jordy Vialoux
@JordyVialoux
May 19 2017 12:44
yes
sorry, I thought my post had explained
Tushar Mathur
@tusharmath
May 19 2017 12:45
R.assoc(['carousel', 'expand'],  !state.carousel.expand , state)
how about this ?
Jordy Vialoux
@JordyVialoux
May 19 2017 12:46
Same thing as before it adds a new property
rather than updating existing.
I assume the R is meant to be return
Tushar Mathur
@tusharmath
May 19 2017 12:47
how can two properties have the same name?
what do u mean adds a new property?
if its already there shouldn't it update it ?
Jordy Vialoux
@JordyVialoux
May 19 2017 12:47
image.png
The top arrow points to the existing carousel object
the bottom points to the new one added by your code
I hope that makes sense
Tushar Mathur
@tusharmath
May 19 2017 12:48
screenshot the code also please
the one u wrote
Jordy Vialoux
@JordyVialoux
May 19 2017 12:49
image.png
Tushar Mathur
@tusharmath
May 19 2017 12:51
use assocPath :)
not assoc
Jordy Vialoux
@JordyVialoux
May 19 2017 12:52
WOOHHOO!!!
Thank you so much man
Tushar Mathur
@tusharmath
May 19 2017 12:52
glad I could be of help
Joey Figaro
@joeyfigaro
May 19 2017 16:01
Morning/afternoon all - another silly question/request: any examples of flattening a nested object into a one-dimensional object?
Bijoy Thomas
@bijoythomas
May 19 2017 16:12
flattenOut = obj => reduce((acc, key) =>
   is(Object, obj[key])? merge(acc, flattenOut(obj[key])) : merge(acc, {[key] : obj[key]}),
   {}, keys(obj))
May not get desired results if there are arrays in the obj
Bijoy Thomas
@bijoythomas
May 19 2017 16:17
If you want dot separated keys for the nesting, the Ramda cookbook has an example: https://github.com/ramda/ramda/wiki/Cookbook#flatten-a-nested-object-into-dot-separated-key--value-pairs
Vadim Nekrasov
@barbiturat
May 19 2017 16:18

Is it possible to create an “accumulator” function via ramda methods?
I need a function, that allows to interact with an argument(s) of previous call.
For example, function, which adds an argument to a previous argument:

adder(5) // => 5
adder(3) // => 8
adder(1) // => 9

Signature of constructor can look like this:

// accum(accumulator, seed);
const adder = accum((current, prev) => current + prev, 0);
Can ramda be useful for this goal? )
shmidt-i
@shmidt-i
May 19 2017 16:19
I think no, since your function is not a pure function :)
Gabe Johnson
@gabejohnson
May 19 2017 16:21
@barbiturat you could define a function that would return a [function, value] pair
Joey Figaro
@joeyfigaro
May 19 2017 16:27
@bijoythomas thanks man
Gabe Johnson
@gabejohnson
May 19 2017 16:28
@barbiturat
const adder = (x, y=0) => (y = x + y, [x => adder(x, y), y]);
Vadim Nekrasov
@barbiturat
May 19 2017 16:45
@gabejohnson thank you! Unexpected solution )
Gabe Johnson
@gabejohnson
May 19 2017 19:35
:thumbsup:
Mika Kalathil
@MikaAK
May 19 2017 21:17
question for all you fper's, i recall hearing that composeP and pipeP was going to get removed, was this false info?
Ian Hofmann-Hicks
@evilsoft
May 19 2017 22:22
oh I hope not. I use the heck out of those
I mean they are easy enough to implement, but gosh it sure is nice having them right there waiting for my grubby little fingers
(by grubby fingers I mean destructuring syntax)
well really only pipeP for (then chains) and pipeK (mostly for future chains). do not really use composeP and composeK.
Michael Rosata
@mrosata
May 19 2017 22:31
I haven't heard that. They don't seem like the sort of thing we'd want to get rid of.
Kevin Wallace
@kedashoe
May 19 2017 22:34
see ramda/ramda#1869 and ramda/ramda#1906