Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Created by Huynh Quang Thao
- # Date: 02/12/2017
- # simple example of currying.
- # finding value of a^base
- def f(base, n)
- return 1 if base == 0
- return n if base == 1
- return n * f(base-1, n)
- end
- square = method(:f).curry[2]
- triple = method(:f).curry[3]
- puts square[4]
- puts triple[3]
Advertisement
Add Comment
Please, Sign In to add comment