perm filename APR09.206[206,LMM] blob
sn#096397 filedate 1974-04-11 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 CLASS NOTES FOR CS 206 - - APRIL 9, 1974
C00012 ENDMK
C⊗;
CLASS NOTES FOR CS 206 - - APRIL 9, 1974
1)Programming difficulty: balancing parentheses.
There are three ways of balancing parentheses:
a)count them from left to right, adding one for each
left parenthesis and subtracting one for each right parenthesis.
Expression is balanced if your count starts and ends at zero
and is never negative.
b)use a right square bracket ("]") at the end of the
expression to automatically provide enough right parentheses
to balance the expression.
c)an altmode (also called "escape" or "enter") has the same
affect as b). Be careful using b) or c), however, as they
may mask errors you made in another part of the expression.
2)Handouts.
a)#7. Homework #2, due April 16.
b)#8. Classnotes from April 4.
c)#9. Sample session with PDP-10.
d)#10. John McCarthy's "Notes on LISP".
3)Administrative Remarks.
a)Typing NEWS.TXT: TY <206LIB>NEWS<alt><cr>
b)Line printer. The IMSSS line printer in Pine Hall is available
for judicious use. Lengthy files only, please. To print a file(machine's
prompts in UPPER CASE, your entries in lower case):
.linepr<cr>
VENTURA OR PINE? p<cr>
FILE(S)
filename<cr>
PINE PRINTING "FILENAME"
DONE
The line printer is available from 7:30 AM to 11 PM; an operator will be
on duty to retrieve your listings.
Additional random notes about the line printer:
-There is no spooling; printer is on-line.
-Several files can be printed; enter multiple filenames separated
by ampersands, or after the above dialogue is completed,
type S to restart the lineprinter program, and the machine
will prompt you for the next file to be printed.
-Control-C will get you out of the lineprinter program without having
to wait for a proper termination as above; however, be sure
then to type RESET to release the line printer.
-If the printer is busy in Pine and the program asks whether the
Ventura printer is suitable, you must answer NO.
-Again, please limit you use of the line printer.
4)Reading assignment.
a)UCI LISP manual, pp. 2.1-2.15(and scan the rest of chap. 2).
b)Weissman, chap. 1,2,3,5.
c)[April 16] UCI LISP manual pp. 1.1-1.16 and Weissman, chap. 6,
7,8,9,10,11,12,14.
5)Continuing about LISP(correcting blunders from last time and creating
new blunders for next time).
Some formal definitions of objects in LISP:
<list> ::= NIL|(<s-expression> . <s-expression>)
<s-expression> ::= <atom>|<list>
<proper list> ::= NIL|(<atom> . <proper list>)
|(<proper list> . <proper list>)
A linear list is a proper list, all of whose elements are atoms. Generally,
a list is a proper list if it is terminated properly, that is, with NIL.
Examples of various LISP notations:
DOT notation: (A . B), (A . NIL), ((3 . 2) . NIL)
LIST notation: We can convert dot to list notation in this way -
if the right hand side of an s-expr of a dotted pair is
a list, drop the . and the right-hand inner parentheses.
examples: (A . NIL) → (A . ( ) ) → (A)
(A . (B . NIL)) → (A . (B)) → (A B)
((A . NIL).(B . NIL)) → ((A) B)
However, (A . B) cannot be converted to list notation.
GRAPH notation (see diagram 1).
MACHINE representation: In the PDP-10, a LISP node is contained in
one 36-bit word, with 18-bit addresses in the left half(CAR) and right
half(CDR). Atoms are represented in unique locations in memory, so all
references to the atom are pointers to the same location.
Convention for representing ariithmetic expressions:
A + B + C * D = A + (B + (C * D))
=(PLUS A (PLUS B (TIMES C D))).
Note that we use PREFIX notation, and that there is explicit
structure and precedence; at a given level, we evaluate from left to right.
Representing a predicate calculus formula:
(∀x)(∃y)(P(x) → Q(x))
may be rendered as (ALL x (EXISTS y (IMPLIES (P x) (Q y))))
6)Text editor.
The time sharing system allows us easily to examine, change,
and undo actions we have performed with or to our programs. The
editor provides us with an "eye" with which we can see one line of
our program. Much of learning to use the editor concerns learning
how to position the eye correctly.
[Aside: if you have made an error and gotten a message of the form
n:, where n is an integer, type control-z to be sure to get back
to the top LISP level, or type BK, BKF, or any of a variety of
break package commands if you are adventurous. When you've had
enough, type ↑↑ to get back to LISP.]
Various editor commands:
#EDITV(X) edit a variable
#EDITF(F) edit a function
#UNDO undo a mistake
#UNDO UNDO undo the last UNDO
#!UNDO undo everything from current editing session
#UNDO !UNDO undo the last !UNDO....etc.
#OK get out of editor, save changes
#SAVE save current edit, can be recalled later
example: edit the expression (A B (C (D) E) F)
#P<cr> prints (A B (C & E) F); this is a level 2 print: prints
top level elements and elements
of sublists, but no sublists of
sublists, or any deeper structures.
#?<cr> prints to level 100.
7)Saving files at the top level of LISP.
Set a variable to a list of the names of the variables or functions
you want to save. For example, if you want to save X and F1:
%SET (LST (X F1] This sets LST(arbitrary name) to list of
things you want to save.
%DSKOUT((filename.ext) LST] You make up a name of a file, calling
it filename.ext, and save LST and its
contents there.
To retrieve the file:
%DSKIN((filename.ext))
YOU ARE URGED NOT TO SQUANDER DISK SPACE!!!