Created
August 8, 2012 15:15
-
-
Save stouset/3295812 to your computer and use it in GitHub Desktop.
Function Composition
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
class Proc | |
def +(other) | |
->(*a1, &b1) do | |
->(*a2, &b2) do | |
inner = other.to_proc.call(*a1, &b1) | |
outer = self .call(inner, *a2, &b2) | |
end | |
end | |
end | |
end | |
class Symbol | |
def +(other) | |
self.to_proc + other | |
end | |
end |
Author
stouset
commented
Aug 8, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment