Skip to content

Instantly share code, notes, and snippets.

@nakajima
Created July 22, 2008 15:32
Show Gist options
  • Select an option

  • Save nakajima/1084 to your computer and use it in GitHub Desktop.

Select an option

Save nakajima/1084 to your computer and use it in GitHub Desktop.
Curry args on a proc. Probably buggy.
class Proc
def curry(*arguments)
if arguments.empty?
return self
else
_proc = self.dup
return lambda do |*args|
return _proc.call(*arguments.concat(args))
end
end
end
end
a = proc { |name, age| puts "#{name} is #{age}" }
b = a.curry('Pat')
b.call(22) # => Pat is 22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment