These are chat archives for ramda/ramda

5th
Mar 2019
Andrew
@foiseworth
Mar 05 08:18

Could anyone possibly explain to me why the following returns undefined rather than what I expect {ref: 2, selected: true}?

const refs = {btts: {ref: 1, selected: false}, abc: {ref: 2, selected: true}}

find(r => r.selected, refs)

https://ramdajs.com/repl/?v=0.26.1#?const%20refs%20%3D%20%7Bbtts%3A%20%7Bref%3A%201%2C%20selected%3A%20false%7D%2C%20abc%3A%20%7Bref%3A%202%2C%20selected%3A%20true%7D%7D%0A%0Afind%28r%20%3D%3E%20r.selected%2C%20refs%29

Rakesh Pai
@rakeshpai
Mar 05 08:19
find expects refs to be an array, but it's an object.
Andrew
@foiseworth
Mar 05 08:20
ahhh so unlike filter and map it doesn't work with objects?
Rakesh Pai
@rakeshpai
Mar 05 08:21
I didn't know filter and map work with objects. TIL. :)
Andrew
@foiseworth
Mar 05 08:22
Yea thats what confused me because I knew they did and then when I tried to use find it didn't :joy:
Thanks for clarifying though - really appreciate it.
Rakesh Pai
@rakeshpai
Mar 05 08:23
No problem.
Mike Chen
@mike442144
Mar 05 10:57
Hey all, Ramda is great! Just one question, why don't we add functions on cookbook to library?
Ben Briggs
@ben-eb
Mar 05 19:33
@mike442144 I don't maintain Ramda but my guess is that it keeps the library more focused - not everyone is going to use or want every function from the cookbook but at least in my experience I use a lot of the main API surface. If you dig around in the issues a bit you may find this sentiment, e.g. https://github.com/ramda/ramda/issues/189#issuecomment-49820256 & https://github.com/ramda/ramda/pull/831#issuecomment-75374873
Johnny Hauser
@m59peacemaker
Mar 05 22:20
I'm possibly in dumb mode....
I have an array of arrays, and I need to zip the arrays together
R.reduce(R.zip, []) seems right to me
Brad Compton (he/him)
@Bradcomp
Mar 05 22:24
R.transpose :question:
Johnny Hauser
@m59peacemaker
Mar 05 22:27
doh, yep
still seems like it would be a zip, though
awkwardly:
reduce(pipe(zip, map(unnest)), head(data), tail(data))
Johnny Hauser
@m59peacemaker
Mar 05 22:35
reduce(zipWith((a, b) => Array.isArray(a) ? [ ...a, b ] : [ a, b ]), head(data), tail(data))
but yeah, I will be using transpose. Thanks!