X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=week1.mdwn;h=b1df1ad5523599929a4241489ab9260cb49fa256;hp=84dc62f8fa9789716a7ea97d7f8ff68abb8413f9;hb=6a60dbeb81ccc4949724a6db13a264a0b322a22d;hpb=ca06027ff5cd69717a72689176e1972efa7325b6 diff --git a/week1.mdwn b/week1.mdwn index 84dc62f8..b1df1ad5 100644 --- a/week1.mdwn +++ b/week1.mdwn @@ -14,7 +14,7 @@ See also: * [Chris Barker's Lambda Tutorial](http://homepages.nyu.edu/~cb125/Lambda) * [Lambda Animator](http://thyer.name/lambda-animator/) -* [Penn lambda calculator](http://www.ling.upenn.edu/lambda/) Pedagogical software developed by Lucas Champollion, Josh Tauberer and Maribel Romero. Linguistically oriented. +* [Penn lambda calculator](http://www.ling.upenn.edu/lambda/) Pedagogical software developed by Lucas Champollion, Josh Tauberer and Maribel Romero. Linguistically oriented. * 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.) @@ -37,7 +37,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: @@ -79,6 +78,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) @@ -127,7 +130,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 @@ -309,7 +312,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 @@ -317,6 +320,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 === @@ -343,6 +356,7 @@ combinatorial logic + Rosetta Stone ============= @@ -380,8 +394,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. @@ -453,9 +468,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: + + * [[!wikipedia Higher-order function]] + * [[!wikipedia First-class function]] - 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. + 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: @@ -689,6 +707,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 ----------------------------------------------