Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. Basic usage pattern of a curry function.
  2.  
  3.  
  4. ```js
  5. const a = [1,2,3,4];
  6. console.log(a.map(x => x*2)); // [2, 4, 6, 8]
  7. ```
  8.  
  9. Here is the same thing using currying.
  10.  
  11. ```js
  12. // Curry function
  13. const mulby = y => x => x*y;
  14.  
  15. // New lambda partion
  16. const mul2 = mulby(2);
  17.  
  18. console.log(a.map(mul2)); // [2, 4, 6, 8]
  19. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement