Introduction to I ❤ Ramda The I ❤ Ramda series will differ slightly from others you may have seen. Instead of using the typical , , examples, or articles demonstrating isolated functions, this series aims to showcase real world applications of Ramda.js. foo bar baz Partial Application with a Special Placeholder If you have used , you may already be familiar with the concept of Partial Application. bind Using we were able to partially apply the value to the argument in the function to create a completely new function . bind 2 a multiply double The above solution (with ) works just fine, even if we do have to call and also pass in the context (in this case it's ). bind bind null Partial Application with Curry The Ramda way of handling Partial Application would be to Curry the function. multiply Okay, so now the code is… , but you’re not excited, and I get that. But hang on because the 🧙 magic is just about to start. different Where bind falls short Let’s consider this example, take a look at lines 9 and 10… All calls to are going to be and now that I think about it, they are all going to use the same function too. readFile utf8 output For this example bind cannot be used because will only apply arguments from left to right. A completely new function would have to be created. bind Special Placeholder Ramda has what they refer to as a Special Placeholder which is used to partially apply arguments regardless of position. To use this Special Placeholder, the function must first be curried. Now that has been curried into , we can use Ramda's Special Placeholder ( ) for the filename argument and partially apply, and to . fs.readFile readFile __ utf8 output readFile 😍 If you are not excited at this point, go see a doctor because you dead inside. Let’s finish this example up with some refactoring. can also be used like this because now we have more options! readFile Homework The best way to learn is to 😉. So for this excercise try to create two new functions and based off of the function . do fetchGet fetchPost fetch If you need help, post questions in the comments section, I’ll do my best to answer every question! What else can we do? Here’s a simplified snippet from a project I am working on. First I’ll stub out the so you can also run this example. tokenContract Again, don’t read too much into this part of the code, it’s just the setup. But notice to how the function is used below. curry Now the meat 🍖 Curry and Partial Application allowed us to trim and off the ends of our function inside . This is a pattern you will see . The single argument supplied from the function (in this case it's ) will become the final argument of the function to be called in . i => , i then often then i tokenContract.getTokenAtIndex Further research: The process of omitting the at the end is called point-free or tacit programming, the argument being the “point”. i i And since I know the work I am doing will always be for , I could apply the value to both functions. account account Extra credit Function composition will be covered in future articles, but right now I’d like leave this as extra credit for you to research and tinker with: Summary This article briefly covered Partial Application, Currying, and even Function Composition. Head over to to learn more. Ask questions in the comments, I will respond to every question! Ramda If you found this interesting, I have more articles on and . Medium dev.to Subscribe on , , and or to be notified of future articles. Twitter Medium dev.to steemit joel.net Cheers! originally posted on github