Prev 12 | Implementing subprograms | Chapter 10 | lab12 LISP102 |
13 | Functional Programming | Chapter 15 not section 8 | lab13 LISP103 |
Next 14 | Data Abstraction | Chapter 2 section 14 + Chapter 11 | lab14 C/C++ ADTs |
I am likely to ask you to program a simple LISP function in the final. These are the kinds of functions that are examples in section 15.5.10 or solutions to one or more the first 5 Problems at the end of the chapter. We will practice functions like these in the next class and in the lab.
Table
Page | Function to Trace |
---|---|
692 | member |
693 | equal |
694 | append |
You can try them out and TRACE them on our computers using XLISP, as long as you translate them.
Table
Page | Scheme | XLISP | Note |
---|---|---|---|
666 | DEFINE | - | OK for functions in our XLISP, but see Note below |
683,684 | DEFINE | - | OK for functions in our XLISP, but see Note below |
684 | DISPLAY - | Depends on the precise semantics of DISPLAY, Try one of these | |
" | " | Prin1 | Print a list of values |
" | " | Princ | Print a list of values without quoting |
" | " | Print a list of values on a new line | |
" | NEWLINE | terpri | terminate print line |
685 | EVEN? | evenp | P stands for Predicate |
" | ODD? | oddp | |
" | ZERO? | zerop | |
" | EQV | = | |
685 | #T | t | |
" | #F | nil | |
686 | ELSE | t | |
690 | EQ? | eq | Built in |
690 | LIST? | consp | I think. |
" | ATOM? | atom | |
691 | NULL? | null | |
692 | member | Predefined in XLISP | |
693 | append | Predefined in XLISP | |
697 | compose | To Be Announced! | |
698... | mapcar | Predefined in XLISP |
To get the static scoping use the defun operator:
. . . . . . . . . ( end of section Preparation) <<Contents | End>>
If Y has value (A . B) (notice the dot), then
We would draw a picture of the memory of the computer like
this:
If Z is a variable that has a simple list (A B ) (notice the absence of a
dot between A and B!) then the
B is in a second dotted pair, linked to the first one like this:
In the above diagram