These are chat archives for ramda/ramda

30th
Sep 2016
Travis LaDuke
@laduke
Sep 30 2016 04:47
const finderer = R.find(R.propEq('id', someVar));
let thingy = finderere(someArray);

How to get to

const finderer = R.find(R.propEq('id', ???))(someVar)(someArray)`

?

James Forbes
@JAForbes
Sep 30 2016 06:15
const finderer = R.compose(R.find, R.propEq('id'))

finderer('wow')([{ id: 'wow' }]) //=> { id: 'wow' }
GÁBOR Áron Zsolt
@ashnur
Sep 30 2016 06:38
Is there a simpler way to do: R.values(R.map(R.prop('attrName'), someObj))?
Stefano Vozza
@svozza
Sep 30 2016 07:34
R.pluck can replace map and prop there
GÁBOR Áron Zsolt
@ashnur
Sep 30 2016 07:44
thanks
Michael van Tricht
@mtricht
Sep 30 2016 11:25
Hi guys, how would I do the following in ramda?
const obj = {x: 1, y: 2, z: 3, g: 5};
const newObj = ramdaMagic(['x', 'y'], obj);
// newObj = {x: 1, y: 2}
Just remembered, pick!
Aldwin Vlasblom
@Avaq
Sep 30 2016 12:00
@swordbeta \o.
James Forbes
@JAForbes
Sep 30 2016 13:17
@swordbeta ramdaMagic = R.pick
oh wait haha
need to learn to read
Francis
@FrancisVega
Sep 30 2016 17:31
How function R.find() is used? I'm trying with R.('a')(['a', 'b']) with no luck :S
Brad Compton (he/him)
@Bradcomp
Sep 30 2016 17:34
@FrancisVega You need to pass in a function as the first argument
R.find
Brad Compton (he/him)
@Bradcomp
Sep 30 2016 17:34
@ram-bot
R.find(R.equals('a'))(['a', 'b'])
ram-bot
@ram-bot
Sep 30 2016 17:34
'a'
Francis
@FrancisVega
Sep 30 2016 17:35
oh! I see.. thanks so much!
:clap:
Travis LaDuke
@laduke
Sep 30 2016 17:37
I'm sure it could be done so @JAForbes kind answer above could be called like finderer('wow', [{id: 'wow'}]) (without having to call it twice) ?
Brad Compton (he/him)
@Bradcomp
Sep 30 2016 17:39
R.eqProps
Brad Compton (he/him)
@Bradcomp
Sep 30 2016 17:39
:point_up: That may get you where you need to go @laduke
Wait, nope
I mixed it up
Travis LaDuke
@laduke
Sep 30 2016 17:41
that's a cool function though
Brad Compton (he/him)
@Bradcomp
Sep 30 2016 17:43
Although there are some point free tricks you could use, I usually go the simple route
const finderer = curry((prop, val, list) => find(propEq(prop, val), list))
Travis LaDuke
@laduke
Sep 30 2016 17:44
ah
What's it called when you move stuff around to find different (point-free) versions? It's like SomeonesName Refactorization.
eta-reduction
Drew
@dtipson
Sep 30 2016 19:04
things like "finderer" make me question not the limits of programming languages, but rather the limits of languages like English to tersely express the meaning of functions
Ryan Zeigler
@rzeigler
Sep 30 2016 20:39
i would probably name finderer findWithPropEq
LeonineKing1199
@LeonineKing1199
Sep 30 2016 20:40
Ooh, that's a good name, actually
It's hard to come up with names on the spot
Travis LaDuke
@laduke
Sep 30 2016 20:41
and after ;)
but am I gonna use findWithPropEq
Ryan Zeigler
@rzeigler
Sep 30 2016 21:00
my go to is smushing things together
when doing partial application
usually works, unless theres some super obvious name that covers it