Skip to content

Instantly share code, notes, and snippets.

@neanias
Created March 25, 2020 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neanias/f9779a019e3cbbbe3fbc778039698ad8 to your computer and use it in GitHub Desktop.
Save neanias/f9779a019e3cbbbe3fbc778039698ad8 to your computer and use it in GitHub Desktop.
# Create a lambda that adds its 2 params
adder = ->(x, y) { x + y }
# Curry it to pre-populate the first param with 2. This effectively turns
# add_two into ->(2, y) { 2 + y }
add_two = adder.curry[2]
# Call add_two with some other args
add_two.call(3)
# => 5
add_two.call(7)
# => 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment