Skip to content

Instantly share code, notes, and snippets.

@stouset
Created August 8, 2012 15:15
Show Gist options
  • Save stouset/3295812 to your computer and use it in GitHub Desktop.
Save stouset/3295812 to your computer and use it in GitHub Desktop.
Function Composition
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
@stouset
Copy link
Author

stouset commented Aug 8, 2012

(:<< + :to_s + :- + :*).(20,5).(1).().(' bottles')
"99 bottles"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment