From 96a8c8c9b81fc914ac7ec368fab0ffa4bcf4177a Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Sun, 24 Oct 2010 17:19:02 -0400 Subject: [PATCH] edits --- assignment5.mdwn | 2 +- week6.mdwn | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/assignment5.mdwn b/assignment5.mdwn index 87d5566c..ccf402ab 100644 --- a/assignment5.mdwn +++ b/assignment5.mdwn @@ -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 - match b with true -> 1 | false -> 2;; + match b with true -> y | false -> n;; also evaluates to 1. Likewise, 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] -- 2.11.0