X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?a=blobdiff_plain;f=week6.mdwn;h=221e02077378f650111c0facbaea9cc9d649eb23;hb=41fb0b5823a475ce615f424d405957820457fe8c;hp=1839455a6542b7df4b9339222295d6f871b14358;hpb=80ad862c64373ac07b6e33236a47a50e98583d62;p=lambda.git diff --git a/week6.mdwn b/week6.mdwn index 1839455a..221e0207 100644 --- a/week6.mdwn +++ b/week6.mdwn @@ -44,9 +44,10 @@ Oh well. 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 @@ -69,8 +70,8 @@ Compare with # 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: @@ -135,7 +136,7 @@ Oh, one more thing: lambda expressions look like this: # (fun x -> x);; - : 'a -> 'a = # (fun x -> x) true;; - - : book = true + - : bool = true (But `(fun x -> x x)` still won't work.) @@ -152,7 +153,7 @@ reverse the order of the arguments: 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]