Skip to content

Instantly share code, notes, and snippets.

@luchiago
Created September 14, 2019 19:38
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 luchiago/3c94e24bbb7f1280bf1c15308ed7d12b to your computer and use it in GitHub Desktop.
Save luchiago/3c94e24bbb7f1280bf1c15308ed7d12b to your computer and use it in GitHub Desktop.
Currying in ruby
#Allows a function accepts n parameters and turns it into a sequence of n functions, each of them take 1 parameter.
power_function = -> (x, z) {
(x) ** z
}
base = gets.to_i
raise_to_power = power_function.curry.(base)
power = gets.to_i
puts raise_to_power.(power)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment