annotate lab3/compose.p @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
rev   line source
mike@0 1 (* lab3/compose.p *)
mike@0 2
mike@0 3 var p;
mike@0 4
mike@0 5 proc compose(f, g);
mike@0 6 proc fg(x);
mike@0 7 begin
mike@0 8 return f(g(x))
mike@0 9 end;
mike@0 10 begin
mike@0 11 return fg
mike@0 12 end;
mike@0 13
mike@0 14 proc dummy(f, g);
mike@0 15 var a0, a1, a2, a3, a4, a5, a6, a7, a8, a9;
mike@0 16 begin
mike@0 17 return compose(f, g)
mike@0 18 end;
mike@0 19
mike@0 20 proc add2(x); begin return x+2 end;
mike@0 21 proc square(x); begin return x * x end;
mike@0 22
mike@0 23 begin
mike@0 24 p := dummy(square, add2);
mike@0 25 print p(2); newline
mike@0 26 end.