These are chat archives for ramda/ramda

3rd
Oct 2015
James Forbes
@JAForbes
Oct 03 2015 13:29
@jdalton keyBy says what it does, but not it's for. I prefer indexBy.
Tom Duncalf
@tomduncalf
Oct 03 2015 16:18

hey, i have a noob question - i'm just experimenting with Ramda after reading the DrBoolean FP eBook, really like what I've seen but am still wrapping my head round it.

i've got a list of items (in this case, bookmarks represented by objects) and i want to filter out any items which are in a second list, based on whether the url matches

my first attempt in JS is:
return allBookmarksList.filter(bookmark => {
    return !(bookmarksToFilterList.filter(bookmarkToFilter => bookmarkToFilter.url === bookmark.url).length);
  });
and i'd love to know how to write this "properly" using Ramda
David Chambers
@davidchambers
Oct 03 2015 16:20
You could start by using R.find rather than filter.
R.find(bkmk => bkmk.url === bookmark.url, bookmarks) != null
Tom Duncalf
@tomduncalf
Oct 03 2015 16:21
that sounds like a good start :)
David Chambers
@davidchambers
Oct 03 2015 16:22
You could then replace the lambda with a partial application of R.propEq.
R.find(R.propEq('url', bookmark.url), bookmarks) != null
Tom Duncalf
@tomduncalf
Oct 03 2015 16:24
ah perfect, propEq is what I was looking for
is there then an elegant way to remove the outer lambda?
David Chambers
@davidchambers
Oct 03 2015 16:25
There may be, but it's not immediately obvious to me.
R.eqProps may help.
Tom Duncalf
@tomduncalf
Oct 03 2015 16:26
cool, that's exactly what i was looking for and i think reads more clearly than the JS version
thanks
by the way, are there any ramda tutorials/guides you would recommend?
David Chambers
@davidchambers
Oct 03 2015 16:26
R.find(R.eqProps('url', bookmark), bookmarks) != null
Raine Virta
@raine
Oct 03 2015 16:27
@tomduncalf check the articles on wiki
Tom Duncalf
@tomduncalf
Oct 03 2015 16:28
ah awesome, i hadn't seen the wiki, was just using http://ramdajs.com/docs/ but it can be a little overwhelming at first ;)
David Chambers
@davidchambers
Oct 03 2015 16:28
No problem! As for guides, we have an open issue, ramda/ramda#1282, for putting together a manual to accompany the API documentation.
Raine Virta
@raine
Oct 03 2015 16:28
it's really good idea to go through all the functions in the docs once
like just skimming through them
Tom Duncalf
@tomduncalf
Oct 03 2015 16:29
yeah that sounds like a good idea, so next time you come across a situation you think "i'm sure there was a function for this"
Raine Virta
@raine
Oct 03 2015 16:29
exactly
Tom Duncalf
@tomduncalf
Oct 03 2015 16:30
i guess i have my afternoon reading sorted then ;)
thanks for the help
the Hardcore Functional Programming in JavaScript course linked from the first blog post looks interesting
Scott Sauyet
@CrossEye
Oct 03 2015 17:44
That was a great course!
Funny that the manual got mentioned here. I am finally back to doing a little work on it.
Won't do a lot at a time as I have two other projects taking up most of my available hours, but I would like to see that make some progress. I cleaned up one section and am hoping to add another section today.
Patricio M. Ros
@pmros
Oct 03 2015 22:49
hi
Raine Virta
@raine
Oct 03 2015 22:56
hello
Patricio M. Ros
@pmros
Oct 03 2015 22:56
I'm happy to know someone is alive
Scott Sauyet
@CrossEye
Oct 03 2015 23:01
never know around here. Crazy active for many hours straight, then dead for days...
Patricio M. Ros
@pmros
Oct 03 2015 23:04
I've created a new github repo and I'm looking for some feedback. Maybe this is not the place to this message.
But I don't kno where I start.
Scott Sauyet
@CrossEye
Oct 03 2015 23:06
If it's in any way related to Ramda, functional programming, or anything else cool, post a link here and someone might take a look.
Patricio M. Ros
@pmros
Oct 03 2015 23:07
It's about pattern matching.
Scott Sauyet
@CrossEye
Oct 03 2015 23:07
go ahead, post a link. We don't bite.... hard. :smile:
thank you
The idea is something like regex but more general
iterables intead strings, predicates instead characters
Patricio M. Ros
@pmros
Oct 03 2015 23:15
see you!
Scott Sauyet
@CrossEye
Oct 03 2015 23:15
First thought: the examples would look a lot better with ES6 fat arrow syntax. (Then you might not need to bother with the Livescript.)
No wait, you say that...
Patricio M. Ros
@pmros
Oct 03 2015 23:17
yes, choose your favorite syntax/dialect
thank you, CrossEye
I have to go, see you!
Scott Sauyet
@CrossEye
Oct 03 2015 23:19
bye