Skip to content

Instantly share code, notes, and snippets.

@osyo-manga
Created February 7, 2015 16:54
Show Gist options
  • Save osyo-manga/c6e759b61c7169ae300f to your computer and use it in GitHub Desktop.
Save osyo-manga/c6e759b61c7169ae300f to your computer and use it in GitHub Desktop.
syan
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