Skip to content

Instantly share code, notes, and snippets.

@depy
Created November 29, 2013 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save depy/7713078 to your computer and use it in GitHub Desktop.
Save depy/7713078 to your computer and use it in GitHub Desktop.
Simple composition of ruby lambdas.
class Proc
def *(f)
->(*args) { self.(f.(*args)) }
end
end
plus2 = ->(n) { n+2 }
plus3 = ->(n) { n+3 }
plus5 = plus2 * plus3
plus5.(5) # returns 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment