fork(2) download
  1. {$modeswitch nestedprocvars}
  2. type
  3. intfunctor = function(x: integer): integer is nested;
  4.  
  5. function compose(f, g: intfunctor): intfunctor;
  6. function h(x: integer): integer;
  7. begin
  8. h := f(g(x))
  9. end;
  10. begin
  11. compose := intfunctor(@h)
  12. end;
  13.  
  14. function dbl(x: integer): integer;
  15. begin
  16. dbl := x * 2
  17. end;
  18.  
  19. function square(x: integer): integer;
  20. begin
  21. square := x * x
  22. end;
  23.  
  24. begin
  25. write(compose(@dbl, @square)(5))
  26. end.
Success #stdin #stdout 0s 336KB
stdin
Standard input is empty
stdout
50