MASSACHVSETTS INSTITVTE OF TECHNOLOGY
Department of Electrical Engineering and Computer Science
6.001--Structure and Interpretation of Computer Programs
Fall Semester, 1998
Lecture Notes, September 9
- Primitives
- Means of combination
- procedure application
- compound data structures
- Means of abstraction
- naming
- procedures
- data abstractions
- 1.
- (Almost) Every expression has a value (which
is returned when the expression is evaluated).
- 2.
- Every value has a type.
- 1.
- If expression is self-evaluating, return value.
- 2.
- If a name, return value associated with that name in
the environment.
- 3.
- If a special form, do something special.
- 4.
- If a combination, then
- (a)
- Evaluate all of the subexpressions of the combination
(in any order).
- (b)
- Apply the operator to the values of the
operands (the arguments) and return the result.
- 1.
- If procedure is primitive (built-in), just do it.
- 2.
- If procedure is a compound procedure, then evaluate
the body of the procedure with each formal parameter
replaced by the corresponding actual argument value.
- Primitive Expressions
- Constants (self-evaluating)
- Numerals, e.g. 7 == Sch-Num 7
- Strings, e.g. "hello" == Sch-String hello
- Booleans, e.g. #f #t == Sch-Bools
- Names
- e.g. + == primitive procedure
- e.g. x == variable
created by define or procedure application
- Compound Expressions
- Combinations: (<operator> <operand> <operand> ...)
- Special Forms
- define: (define <name> <exp>)
- lambda: (lambda (<formal1> <formal2> ...) <body>)
- if: (if <predicate> <consequent> <alternative>)
- ... more to come! ...
(define try
(lambda (guess x)
(if (good-enuf? guess x)
guess
(try (improve guess x) x))))
(define improve
(lambda (guess x)
(average guess (/ x guess))))
(define average
(lambda (a b)
(/ (+ a b) 2)))
(define good-enuf?
(lambda (guess x)
(< (abs (- (square guess) x)) 0.001)))
(define sqrt
(lambda (x) (try 1 x)))
This document was generated using the
LaTeX2HTML translator Version 98.1p1 release (March 2nd, 1998)
Copyright © 1993, 1994, 1995, 1996, 1997,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
The command line arguments were:
latex2html lec1.
The translation was initiated by Duane Boning on 1998-09-10
Duane Boning
1998-09-10