Fundamentals of CS I (CS151 2001S) : Reference

list? - determine if a value is a list

Procedurelist?
Parametersval, a value
PurposeDetermines if val is a list (and can therefore be used as a parameter to car and cdr).
ProducesA truth value: true (#t) if val is a list, false (#f) if it's not a list.
PreconditionsOnly one parameter (verified).
Examples
> (list? ())
#t
> (list? (cons 'a null))
#t
> (list? (list 'a 'b 'c))
#t
> (list? 'a)
#f
> (list? cons)
#f
> (list? 'cons)
#f
> (list? "cons")
#f

Disclaimer: I usually create these pages on the fly. This means that they are rarely proofread and may contain bad grammar and incorrect details. It also means that I may update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This page was generated by Siteweaver on Thu Feb 22 05:48:04 2001.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2001S/list-p.html.
You may validate this page's HTML.
The source was last modified Fri Feb 2 06:34:48 2001.