X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=topics%2Fweek1.mdwn;h=f195b8d9216207fa5c83c29e0cab3013d667df87;hp=725c4d18dc8ce3edec89428701071f9f4e9b12b5;hb=441659b7ec458cc0b45a1da299f0466dc89f1266;hpb=9ca52fa8a329edc6975f0aa19856a4a8d782ad77;ds=sidebyside diff --git a/topics/week1.mdwn b/topics/week1.mdwn index 725c4d18..f195b8d9 100644 --- a/topics/week1.mdwn +++ b/topics/week1.mdwn @@ -473,7 +473,7 @@ or, using `case`:   `factorial match` λ `n. case n of 0 then 1; _ then n * factorial (n - 1) end` `in factorial` -But there's a problem here. What value does `factorial` have when evaluating the expression `factorial (n - 1)`? +But there's a problem here. What value does `factorial` have when evaluating the subexpression `factorial (n - 1)`? As we said in class, the natural precedent for this with non-function variables would go something like this: @@ -540,7 +540,7 @@ Finally, we're in a position to revisit the two definitions of `length` that Jim   `length match` λ `xs. case xs of [] then 0; _:ys then 1 + length ys end` `in length` -This function accept a sequence `xs`, and if its empty returns `0`, else it says that its length is `1` plus whatever is the length of its remainder when you take away the first element. In programming circles, this remainder is commonly called the sequence's "tail" (and the first element is its "head"). +This function accept a sequence `xs`, and if it's empty returns `0`, else it says that its length is `1` plus whatever is the length of its remainder when you take away the first element. In programming circles, this remainder is commonly called the sequence's "tail" (and the first element is its "head"). Thus if we evaluated `length [10, 20, 30]`, that would give the same result as `1 + length [20, 30]`, which would give the same result as `1 + (1 + length [30])`, which would give the same result as `1 + (1 + (1 + length []))`. But `length []` is `0`, so our original expression evaluates to `1 + (1 + (1 + 0))`, or `3`.