Contents    Page-10    Prev    Next    Page+10    Index   

List Access Functions

There are easy rules for the access functions using the parenthesized representation of lists:

first returns the first thing in a list. A thing is:

(first '(a b c))       ->  a

(first '((a b) c))     ->  (a b)

rest returns the rest of a list after the first thing. Simply move the left parenthesis to the right past the first thing.

(rest '(a b c))           ->  (b c)

(rest '((a b) c))         ->  (c)

(rest (rest '((a b) c)))  ->  () = null