X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=topics%2Fweek1.mdwn;h=5ab30bcb0617e8aed9f994a8e641d0de6151ddc9;hp=82e1fa63b3f944c2b59cd780f1ea994386092cb5;hb=a7c26ba13dbf72718f66e8814f4cf74ec4647000;hpb=d7dd23c2ace59bf557f247e57fe75190a4d1e798 diff --git a/topics/week1.mdwn b/topics/week1.mdwn index 82e1fa63..5ab30bcb 100644 --- a/topics/week1.mdwn +++ b/topics/week1.mdwn @@ -81,7 +81,7 @@ I've started throwing in some **variables**. We'll say variables are any express x? xs -We'll follow a *convention* of using variables with short names and a final `s` to represent collections like sequences (to be discussed below). But this is just a convention to help us remember what we're up to, not a strict rule of the language. We'll also follow a convention of only using variables ending in `?` to represent functions that return a boolean value. Thus, for example, `zero?` will be a function that expects a single number argument and returns a boolean corresponding to whether that number is `0`. `odd?` will be a function that expects a single number argument and returns a boolean corresponding to whether than number is odd. Above, I suggested we might use `lessthan?` to represent a function that expects *two* number arguments, and again returns a boolean result. +We'll follow a *convention* of using variables with short names and a final `s` to represent collections like sequences (to be discussed below). But this is just a convention to help us remember what we're up to, not a strict rule of the language. We'll also follow a convention of only using variables ending in `?` to represent functions that return a boolean value. Thus, for example, `zero?` will be a function that expects a single number argument and returns a boolean corresponding to whether that number is `0`. `odd?` will be a function that expects a single number argument and returns a boolean corresponding to whether than number is odd. Above, I suggested we might use `lessthan?` to represent a function that expects *two* number arguments, and again returns a boolean result. We also conventionally reserve variables ending in `!` for a different special class of functions, that we will explain later in the course. @@ -383,7 +383,7 @@ is a pattern, meaning the same as `x1 & x2 & []`. Note that while `x & xs` match For the time being, these are the only patterns we'll allow. But since the definition of patterns is recursive, this permits very complex patterns. What would this evaluate to: let - ([xs, ys], [z:zs, ws]) match ([[], [1]], [[10, 20, 30], [0]]) + ([xs, ys], [z & zs, ws]) match ([[], [1]], [[10, 20, 30], [0]]) in z & ys Also, we will permit complex patterns in λ-expressions, too. So you can write: