next up previous contents index
Next: List Manipulation Up: Basics Previous: Basics

Lists

 

A list  is a sequence of S-expressions, separated by whitespace (spaces, tabs, newlines, and formfeeds), and surrounded by parentheses. Note that each S-expression can itself be a list, so the following are all valid lists: (1 2 3), (1 (2 3)), (1 (2 (3))), etc. In addition, a special list is defined that has no elements. This is called the empty list , or the null list , and is written ()  or nil .

Lists may be left unevaluated in the same manner as atoms, by quoting them.

 
		 '(1 2 3) 		  tex2html_wrap_inline972  		 (1 2 3)

If a list is to be evaluated, its first element is considered to be a function  name, and the remaining elements are arguments to that function. The number of arguments a function expects is called its arity . For instance, the addition function is called ` +', and it has an arity of two. For example,
 
		 (+ 2 3) 		  tex2html_wrap_inline972  		 5

As with all lists, the arguments to a function  may themselves be function calls. For example,
 
		 (+ (+ 2 3) (+ 5 6)) 		  tex2html_wrap_inline972  		 16



Steven J. Zeil
Tue Mar 4 14:36:27 EST 1997