Held Monday, January 29, 2001
Today we consider two of Scheme's most important types of data:
symbolic values and lists.
- Are there any questions on the
reading on lists?
- Quiz (paper).
- Are there any questions on
- I hope to send out information on combining logical and physical
formatting this evening. (It depends a lot on how the weather
- A short history of Scheme
- Symbolic values
- Scheme is a variant of Lisp (the List processing language).
- Lisp is one of the oldest high-level programming languages in
- It's from about the time of the invention of Cobol and only a few
years after the invention of Fortran.
- John McCarthy (of MIT and then Stanford) designed Lisp to provide a
language for programming in artificial intelligence.
- At the time, many people believed that intelligence was grounded
in symbolic processing.
- Lisp added many things to languages of the day:
- Symbolic values
- Dynamic lists as built-in data structures
- Automatic memory managment for those built-in data structures
- Functions as values (we'll return to this in a few weeks)
- In later reflection, McCarthy indicated that some of these things
were just luck. For example, the
lambda that you'll
learn about soon was just a "hmmm ... that sounds interesting, I'll
put it in" fluke.
- Scheme was designed in the early 1980's (or maybe late 1970's) as
a variant of Lisp more appropriate for teaching computer science
(and doing many other things; it's more elegant).
- Scheme has a slightly clearer semantics than Lisp (and a formal
semantics, which is important).
- Scheme adds some nifty features for advanced programmers.
- But, at least for 151, you're doing Lisp-like programming.
- A key aspect of Scheme (see above).
- The easiest way to build a symbol is with the quote operation.
reference to undefined identifier: a
> (quote a)
- Useful when you want to represent something atomically (as an idea
that can't be pulled apart).
- The core of Scheme.
- Dynamic: Lists can "grow" and "shrink"
- Or at least you can build larger or smaller lists from
- The simplest list: the empty list is
- You extend a list at the front (or, more precisely, build a
new list) with
(cons thing-for-the-front rest-of-the-list)
- For example,
> (cons 'a null)
> (cons 'b (cons 'a null))
- You can also create lists with
> (list 'a 'b 'c)
(a b c)
- You extract parts of lists with three operations (we'll reflect on
the naming later in the semester):
car: get the initial element of the list.
cdr: get all but the initial element of the list.
list-ref: get the ith element of the list.
- One disadvantage: Scheme lists look a lot like procedure
applications, so it's sometimes hard for beginning programmers
to tell what's going on.
- You can always tell by context, but it takes some time to
get used to contexts.
- Do the lists lab.
- We'll try to use the last five minutes of class to reflect.
- You may have to complete the remainder of the lab on your own.
Friday, 12 January 2001
- Created generic outline format for class.