Skip to content

Instantly share code, notes, and snippets.

@thypon
Created March 12, 2015 22:55
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 thypon/86add332b6d85b9abb39 to your computer and use it in GitHub Desktop.
Save thypon/86add332b6d85b9abb39 to your computer and use it in GitHub Desktop.
Proc Composability
class Proc
def self.compose(f, g)
lambda { |*args| f[g[*args]] }
end
def *(g)
Proc.compose(self, g.to_proc)
end
def |(g)
Proc.compose(g.to_proc, self)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment