Created
July 12, 2020 13:31
-
-
Save codertcet111/9487b938eacf4b12d5e79dd2266795ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum(a, *b) | |
a + b.inject(0) { |a, b| a + b} | |
end | |
sum_of_all = method(:sum).curry(3) | |
puts method(:sum) | |
puts "Normal Sum: #{sum(1,2,3)}" | |
puts "Curried Sum 👇:" | |
(1..3).each do |n| | |
sum_of_all = sum_of_all.call(n) | |
puts sum_of_all | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment