Created
July 11, 2013 09:10
-
-
Save supki/5973886 to your computer and use it in GitHub Desktop.
M
This file contains 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
#!/usr/bin/ruby | |
# -*- coding: utf-8 -*- | |
class Function | |
attr_reader :block | |
def initialize &block | |
@block = block | |
end | |
def -@ | |
self | |
end | |
def < other | |
Function.new { |x| block[other.block[x]] } | |
end | |
end | |
puts (Function.new { |x| x + 1 } <- Function.new { |x| x * 3 }).block[2] | |
# => 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment