Higher-order functions: Difference between revisions
Content deleted Content added
→Pointer: Removed syntax highlighting |
→[[JavaScript]]: Added Pascal |
||
Line 199:
var result = first(second);
result = first(function() { return "third"; });
==[[Pascal]]==
[[Category:Pascal]]
Standard Pascal (will not work with Turbo Pascal):
program example(output);
function first(function f(x: real): real): real;
begin
first := f(1.0) + 2.0;
end;
function second(x: real): real;
begin
second = x/2.0;
end;
begin
writeln(first(second));
end.
Turbo Pascal (will not work with Standard Pascal):
program example;
type
FnType = function(x: real): real;
function first(f: FnType): real;
begin
first := f(1.0) + 2.0;
end;
function second(x: real): real;
begin
second := x/2.0;
end;
begin
writeln(first(second));
end.
==[[Perl]]==
|