X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=week1.mdwn;h=5ea3f421e69234c88e0fd974a486ad61e580fae0;hp=3e5c40d508ead0066c3172469ea9467cc63eda86;hb=49e6889d3ceb77526298a84549df44871caaf7a0;hpb=4adc29cc1833361d36c224edb4712f2c33b1fdd8 diff --git a/week1.mdwn b/week1.mdwn index 3e5c40d5..5ea3f421 100644 --- a/week1.mdwn +++ b/week1.mdwn @@ -10,13 +10,7 @@ Sometimes these notes will expand on things mentioned only briefly in class, or Basics of Lambda Calculus ========================= -See also: - -* [Chris Barker's Lambda Tutorial](http://homepages.nyu.edu/~cb125/Lambda) -* [Lambda Animator](http://thyer.name/lambda-animator/) -* MORE - -The lambda calculus we'll be focusing on for the first part of the course has no types. (Some prefer to say it instead has a single type---but if you say that, you have to say that functions from this type to this type also belong to this type. Which is weird.) +The lambda calculus we'll be focusing on for the first part of the course has no types. (Some prefer to say it instead has a single type---but if you say that, you have to say that functions from this type to this type also belong to this type. Which is weird... In fact, though, such types are studied, under the name "recursive type." More about these later in the seminar.) Here is its syntax: @@ -36,7 +30,6 @@ We'll tend to write (λa M) as just `(\a M)`, so we don't hav Application: (M N) -Some authors reserve the term "term" for just variables and abstracts. We'll probably just say "term" and "expression" indiscriminately for expressions of any of these three forms. Examples of expressions: @@ -78,6 +71,10 @@ For instance: The first occurrence of `x` in T is free. The `\x` we won't regard as containing an occurrence of `x`. The next occurrence of `x` occurs within a form that begins with `\x`, so it is bound as well. The occurrence of `y` is bound; and the occurrence of `z` is free. +To read further: + +* [[!wikipedia Free variables and bound variables]] + Here's an example of beta-reduction: ((\x (y x)) z) @@ -126,7 +123,7 @@ because here the second occurrence of `y` is no longer free. There is plenty of discussion of this, and the fine points of how substitution works, in Hankin and in various of the tutorials we've linked to about the lambda calculus. We expect you have a good intuitive understanding of what to do already, though, even if you're not able to articulate it rigorously. -* MORE +* [More discussion in week 2 notes](/week2/#index1h1) Shorthand @@ -308,7 +305,7 @@ Finally, you'll see the term **dynamic** used in a variety of ways in the litera * dynamic versus static typing -* dynamic versus lexical scoping +* dynamic versus lexical [[!wikipedia Scope (programming) desc="scoping"]] * dynamic versus static control operators @@ -316,6 +313,16 @@ Finally, you'll see the term **dynamic** used in a variety of ways in the litera For the most part, these uses are only loosely connected to each other. We'll tend to use "imperatival" to describe the kinds of semantic properties made available in dynamic semantics, languages which have robust notions of sequencing changes, and so on. +To read further about the relation between declarative or functional programming, on the one hand, and imperatival programming on the other, you can begin here: + +* [[!wikipedia Declarative programming]] +* [[!wikipedia Functional programming]] +* [[!wikipedia Purely functional]] +* [[!wikipedia Referential transparency (computer science)]] +* [[!wikipedia Imperative programming]] +* [[!wikipedia Side effect (computer science) desc="Side effects"]] + + Map === @@ -323,7 +330,7 @@ Map Scheme (functional part) OCaml (functional part) -C, Java, Pasval
+C, Java, Python
Scheme (imperative part)
OCaml (imperative part) @@ -342,14 +349,13 @@ combinatorial logic + Rosetta Stone ============= Here's how it looks to say the same thing in various of these languages. -The following site may be useful; it lets you run a Scheme interpreter inside your web browser: - -* [Try Scheme in your web browser](http://tryscheme.sourceforge.net/) +The following site may be useful; it lets you run a Scheme interpreter inside your web browser: [Try Scheme in your web browser](http://tryscheme.sourceforge.net/). See also our links about [[learning Scheme]] and [[learning OCaml]].   @@ -379,8 +385,9 @@ The following site may be useful; it lets you run a Scheme interpreter inside yo ((foo 2) 3) - These functions are "curried". MORE - `foo 2` returns a `2`-fooer, which waits for an argument like `3` and then foos `2` to it. `( + ) 2` returns a `2`-adder, which waits for an argument like `3` and then adds `2` to it. + These functions are "curried". `foo 2` returns a `2`-fooer, which waits for an argument like `3` and then foos `2` to it. `( + ) 2` returns a `2`-adder, which waits for an argument like `3` and then adds `2` to it. For further reading: + +* [[!wikipedia Currying]] In Scheme, on the other hand, there's a difference between `((foo 2) 3)` and `(foo 2 3)`. Scheme distinguishes between unary functions that return unary functions and binary functions. For our seminar purposes, it will be easiest if you confine yourself to unary functions in Scheme as much as possible. @@ -452,9 +459,12 @@ The following site may be useful; it lets you run a Scheme interpreter inside yo 3. Anonymous functions - Functions are "first-class values" MORE in the lambda calculus, in Scheme, and in OCaml. What that means is that they can be arguments to, and results of, other functions. They can be stored in data structures. And so on. + Functions are "first-class values" in the lambda calculus, in Scheme, and in OCaml. What that means is that they can be arguments to, and results of, other functions. They can be stored in data structures. And so on. To read further: - First, we'll show what "anonymous" functions look like. These are functions that have not been bound as values to any variables. That is, there are no variables whose value they are. + * [[!wikipedia Higher-order function]] + * [[!wikipedia First-class function]] + + We'll begin by looking at what "anonymous" functions look like. These are functions that have not been bound as values to any variables. That is, there are no variables whose value they are. In the lambda calculus: @@ -688,6 +698,10 @@ The following site may be useful; it lets you run a Scheme interpreter inside yo When a previously-bound variable is rebound in the way we see here, that's called **shadowing**: the outer binding is shadowed during the scope of the inner binding. + See also: + + * [[!wikipedia Variable shadowing]] + Some more comparisons between Scheme and OCaml ----------------------------------------------