Skip to content

Instantly share code, notes, and snippets.

@ackintosh
Created April 22, 2013 00:10
Show Gist options
  • Save ackintosh/5431663 to your computer and use it in GitHub Desktop.
Save ackintosh/5431663 to your computer and use it in GitHub Desktop.
Currying and Partial application in Ruby
# 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