Skip to content

Instantly share code, notes, and snippets.

@rajinder-yadav
Last active February 21, 2017 05:33
Show Gist options
  • Save rajinder-yadav/4fa70d5013ea24cabe77f5aeaef70a3c to your computer and use it in GitHub Desktop.
Save rajinder-yadav/4fa70d5013ea24cabe77f5aeaef70a3c to your computer and use it in GitHub Desktop.
Curry function.

Curry in a hurry ... very, very good!!!

Showing the basic usage pattern of a curry function.

We start off with this:

const a = [1,2,3,4];
console.log(a.map(x => x*2));  // [2, 4, 6, 8]

Here is the same thing using currying.

// Curry function
const mulby = y => x => x*y;

// New lambda partion
const mul2 = mulby(2);        

// See how nice and hip the code reads.
console.log(a.map(mul2));      // [2, 4, 6, 8]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment