spam / bugbear.com (Paul Graham) writes:

> I'm writing something showing how you'd write the same
> simple program in various different languages.  I'd
> appreciate it if some Ruby expert could tell me the
> canonical way to write in Ruby what you would express
> in Scheme as
> 
> (define (foo x) (lambda (y) (set! x (+ x y))))
> 
> or Perl 5 as
> 
> sub foo {
>   my ($n) = @_;
>   return sub {return $n += shift}}
> 
% cat curry.rb
def foo x
  lambda {|y| x + y}
  # proc {|y| x + y}
  # Proc.new {|y| x + y}
end

p foo(3).call(5)
p foo(3)[5]

bar = foo 3
p bar[5]
p bar.call 5
% 

% ruby curry.rb
8
8
8
8
%

-- Ed