From cddaaa939b1b1af89dea38afa0d9e71f008050f7 Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Sat, 18 Sep 2010 17:39:48 -0400 Subject: [PATCH] tweaked week3 Signed-off-by: Jim Pryor --- week3.mdwn | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/week3.mdwn b/week3.mdwn index 07a14f5b..1f1b6325 100644 --- a/week3.mdwn +++ b/week3.mdwn @@ -19,8 +19,9 @@ In Scheme you'd define it like this: Some comments on this: - 1. `null?` is Scheme's way of saying `isempty`. That is, `(null? lst)` returns true (which Scheme writes as `#t`) iff `lst` is the empty list (which Scheme writes as `'()` or `(list)`). - 2. `cdr` is function that gets the tail of a Scheme list. (By definition, it's the function for getting the second member of an ordered pair. It just turns out to return the tail of a list because of the particular way Scheme implements lists.) +1. `null?` is Scheme's way of saying `isempty`. That is, `(null? lst)` returns true (which Scheme writes as `#t`) iff `lst` is the empty list (which Scheme writes as `'()` or `(list)`). + +2. `cdr` is function that gets the tail of a Scheme list. (By definition, it's the function for getting the second member of an ordered pair. It just turns out to return the tail of a list because of the particular way Scheme implements lists.) What is the `let rec` in the OCaml code and the `letrec` in the Scheme code? These work like the `let` expressions we've already seen, except that they let you use the variable `get_length` *inside* the body of the function being bound to it---with the understanding that it will there refer to the same function that you're then in the process of binding to `get_length`. In OCaml: -- 2.11.0