Created
April 22, 2013 00:10
-
-
Save ackintosh/5431663 to your computer and use it in GitHub Desktop.
Currying and Partial application in Ruby
This file contains hidden or 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
# see also | |
# http://ja.wikipedia.org/wiki/%E3%82%AB%E3%83%AA%E3%83%BC%E5%8C%96 | |
# before | |
div = -> x, y { x / y } | |
p div.call(6, 2)# 6 | |
# currying | |
cdiv = -> x { return -> y { x / y } } | |
# partial application | |
inv = cdiv.call(6) | |
p inv.call(2)# 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment