next up previous
Contents Next: reverse (FUNCTION) Up: Appendix: Selected LISP Previous: or (FUNCTION)


Format: (read <instream> <eof-error> <eof-value> <recursive>)

Required arguments: none

Optional arguments: 4

<instream>: an expression which returns an input stream <eof-error>: any LISP expression <eof-value>: any LISP expression <recursive>: any LISP expression

Called with no arguments, read waits for input from the standard input (usually the keyboard) and returns a LISP object. If <instream> is specified, input is taken from the stream rather than standard input. If <eof-error> is specified it controls what happens if an end of file is encountered in the middle of a ``read.'' If <eof-error> is nil, no error results, and the result of <eof-value> is returned by ``read.'' If <eof-error> is not NIL, then encountering the end of a file during a read will cause an error to occur. <recursive> controls the kind of error that is signalled when an end of file is encountered. If <recursive> is specified and is not NIL, then the end of file is reported to have occurred in the middle of reading in an object. If it is NIL, the the end of file is reported as occurring between objects.

Examples: See chapter 5.

Format: (rest <expr>)

Required arguments: 1

<expr>: any LISP expression which returns a list

The argument expression must evaluate to a list. rest returns the list without its first element. If the list is empty, i.e. is NIL, rest returns NIL.


> (rest '(1 2 3))
(2 3)

> (rest '((a (b (c)) d) e (f)))
(E (F))

> (rest ())

> (rest 'a)
Error: A is not of type LIST

© Colin Allen & Maneesh Dhagat
November 1999