Skip to content

Instantly share code, notes, and snippets.

@supki
Created July 11, 2013 09:10
Show Gist options
  • Save supki/5973886 to your computer and use it in GitHub Desktop.
Save supki/5973886 to your computer and use it in GitHub Desktop.
M
#!/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