I am trying to make the following function pointfree. I am not sure how I can pass the arguement to the inner function though. I am using Ramda.js, but I think the concept is more general than that. Here is the code I have.
search = function(id) {
return find(propEq('id', id), items)
}
Here, you will notice that the id
parameter is passed to the inner function propEq
. That's the part I am unsure of.
The question is more general than Ramda, but Ramda does have several functions to make things like this easier, especially useWith
and converge
.
This can be written points-free with useWith
like this:
var search = useWith(find, propEq('id'), identity);
search(2, items); //=> {id: 2}
You can see it in action on the Ramda REPL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With