Currying: Difference between revisions

{{Out}}
(→‎{{header|Groovy}}: new solution)
({{Out}})
Line 238:
end</lang>
 
{{Out}}
Output:
<pre>
->curry
Line 358:
In[2]:= curry = Function[{x}, Function[{y}, Function[{z}, x[y, z]]]];
 
{{Out}}
Output:
<pre>
 
In[3]:= Plus[2,3]
Out[3]:= 5
Line 368:
In[5]:= curry[Plus][2][3]
Out[5]:= 5
</pre>
 
=={{header|Nemerle}}==
Line 506 ⟶ 507:
add: procedure; $=arg(1); do j=2 to arg(); $=$+arg(j); end; return $
add2: procedure; return add(arg(1), 2)</lang>
{{Out}}
'''output'''
<pre>
add 2 to 3: 5
Line 529 ⟶ 530:
 
=={{header|Ruby}}==
The curry method was added in Ruby 1.9.1. It takes an optional arity argument, which determines the number of arguments to be passed to the proc. If that number is not reached, the curry method returns a new curried method for the rest of the arguments. (Examples taken from the documentation).
If that number is not reached, the curry method returns a new curried method for the rest of the arguments. (Examples taken from the documentation).
<lang ruby>
b = proc {|x, y, z| (x||0) + (y||0) + (z||0) }
Anonymous user