Accumulator factory: Difference between revisions
Content added Content deleted
(Add complicated generic solution for Rust) |
MaiconSoft (talk | contribs) No edit summary |
||
Line 860: | Line 860: | ||
drop accum 3 |
drop accum 3 |
||
!print x 2.3</lang> |
!print x 2.3</lang> |
||
=={{header|Delphi}}== |
|||
{{libheader| System.SysUtils}} |
|||
{{libheader| System.Variants}} |
|||
<lang Delphi> |
|||
program Accumulator_factory; |
|||
{$APPTYPE CONSOLE} |
|||
uses |
|||
System.SysUtils, |
|||
System.Variants; |
|||
type |
|||
TFn = TFunc<variant, variant>; |
|||
function Foo(n: variant): TFn; |
|||
begin |
|||
Result := |
|||
function(i: variant): variant |
|||
begin |
|||
n:= n + i; |
|||
Result := n; |
|||
end; |
|||
end; |
|||
begin |
|||
var x := Foo(1); |
|||
x(5); |
|||
Foo(3); // do nothing |
|||
Writeln(x(2.3)); |
|||
Readln; |
|||
end.</lang> |
|||
=={{header|E}}== |
=={{header|E}}== |
||
<lang e>def foo(var x) { |
<lang e>def foo(var x) { |