diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lab3/compose.p	Thu Oct 05 08:04:15 2017 +0100
@@ -0,0 +1,26 @@
+(* lab3/compose.p *)
+
+var p;
+
+proc compose(f, g);
+  proc fg(x);
+  begin
+    return f(g(x))
+  end;
+begin
+  return fg
+end;
+
+proc dummy(f, g);
+  var a0, a1, a2, a3, a4, a5, a6, a7, a8, a9;
+begin
+  return compose(f, g)
+end;
+
+proc add2(x); begin return x+2 end;
+proc square(x); begin return x * x end;
+
+begin
+  p := dummy(square, add2);
+  print p(2); newline
+end.