Currying: Difference between revisions

no edit summary
m (→‎another implementation: use an unique env table variable instead)
No edit summary
Line 254:
<pre>Add 2 to 3: 5
Add 2 to 3 (curried): 5</pre>
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{Trans|C#}}
<lang Delphi>
program Currying;
 
{$APPTYPE CONSOLE}
{$R *.res}
 
uses
System.SysUtils;
 
var
Plus: TFunc<Integer, TFunc<Integer, Integer>>;
 
begin
Plus :=
function(x: Integer): TFunc<Integer, Integer>
begin
result :=
function(y: Integer): Integer
begin
result := x + y;
end;
end;
 
Writeln(Plus(3)(4));
Writeln(Plus(2)(Plus(3)(4)));
readln;
end.
</lang>
{{out}}
<pre>
7
9
</pre>
=={{header|EchoLisp}}==
[[EchoLisp]] has native support for curry, which is implemented thru closures, as shown in [[CommonLisp]] .
478

edits