edits
authorChris Barker <barker@kappa.linguistics.fas.nyu.edu>
Sun, 24 Oct 2010 21:19:02 +0000 (17:19 -0400)
committerChris Barker <barker@kappa.linguistics.fas.nyu.edu>
Sun, 24 Oct 2010 21:19:02 +0000 (17:19 -0400)
assignment5.mdwn
week6.mdwn

index 87d5566..ccf402a 100644 (file)
@@ -75,7 +75,7 @@ This almost works.  For instance,
 evaluates to 1, and 
 
     let b = true in let y = 1 in let n = 2 in 
 evaluates to 1, and 
 
     let b = true in let y = 1 in let n = 2 in 
-    match b with true -> 1 | false -> 2;;
+    match b with true -> y | false -> n;;
 
 also evaluates to 1.  Likewise,
 
 
 also evaluates to 1.  Likewise,
 
index 1839455..221e020 100644 (file)
@@ -44,9 +44,10 @@ Oh well.
 Booleans in OCAML, and simple pattern matching
 ----------------------------------------------
 
 Booleans in OCAML, and simple pattern matching
 ----------------------------------------------
 
-Where we would write `true 1 2` and expect it to evaluate to `1`, in
-OCAML boolean types are not functions (equivalently, are functions
-that take zero arguments).  Choices are made as follows:
+Where we would write `true 1 2` in our pure lambda calculus and expect
+it to evaluate to `1`, in OCAML boolean types are not functions
+(equivalently, are functions that take zero arguments).  Selection is
+accomplished as follows:
 
     # if true then 1 else 2;;
     - : int = 1
 
     # if true then 1 else 2;;
     - : int = 1
@@ -69,8 +70,8 @@ Compare with
     # match 3 with 1 -> 1 | 2 -> 4 | 3 -> 9;;
     - : int = 9
 
     # match 3 with 1 -> 1 | 2 -> 4 | 3 -> 9;;
     - : int = 9
 
-Unit
-----
+Unit and thunks
+---------------
 
 All functions in OCAML take exactly one argument.  Even this one:
 
 
 All functions in OCAML take exactly one argument.  Even this one:
 
@@ -135,7 +136,7 @@ Oh, one more thing: lambda expressions look like this:
     # (fun x -> x);;
     - : 'a -> 'a = <fun>
     # (fun x -> x) true;;
     # (fun x -> x);;
     - : 'a -> 'a = <fun>
     # (fun x -> x) true;;
-    - : book = true
+    - : bool = true
 
 (But `(fun x -> x x)` still won't work.)
 
 
 (But `(fun x -> x x)` still won't work.)
 
@@ -152,7 +153,7 @@ reverse the order of the arguments:
 
 Infinite loop.
 
 
 Infinite loop.
 
-Now consider the following differences:
+Now consider the following variations in behavior:
 
     # let test = omega omega;;
     [Infinite loop, need to control c out]
 
     # let test = omega omega;;
     [Infinite loop, need to control c out]