Currying: Difference between revisions

Content added Content deleted
(Promotions!)
No edit summary
Line 141: Line 141:
Prelude> :type nested_plus
Prelude> :type nested_plus
nested_plus :: Integer -> Integer -> Integer
nested_plus :: Integer -> Integer -> Integer

==Icon and {{header|Unicon}}==

This version only works in Unicon because of the coexpression calling syntax
used.

<lang unicon>procedure main(A)
add2 := addN(2)
write("add2(7) = ",add2(7))
write("add2(1) = ",add2(1))
end

procedure addN(n)
return makeProc{ repeat { (x := (x@&source)[1], x +:= n) } }
end

procedure makeProc(A)
return (@A[1], A[1])
end</lang>

Output:
<pre>
->curry
add2(7) = 9
add2(1) = 3
->
</pre>


=={{header|Io}}==
=={{header|Io}}==