Created
February 7, 2015 16:54
-
-
Save osyo-manga/c6e759b61c7169ae300f to your computer and use it in GitHub Desktop.
syan
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
class Proc | |
def + rhs | |
lambda { |*args| self[*args] + rhs.to_proc[*args] } | |
end | |
end | |
def value val | |
lambda { |*args| val } | |
end | |
def argument index | |
lambda { |*args| args[index] } | |
end | |
arg1 = argument 0 | |
arg2 = argument 1 | |
puts value(10).to_proc[] | |
puts (value(10) + arg1).to_proc[42] | |
puts (1..4).map &(arg1 + value(3)) | |
puts (1..4).inject &(arg1 + arg2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment