Fundamentals of CS I (CS151 2001S) : Reference

length: determine list length

Parametersl, a list
PurposeDetermines the number of elements in the list. Counts each sublist as one element.
ProducesAn integer that corresponds to the number of elements in the list.
PreconditionsOne parameter (verified).
l is a list (verified).
PostconditionsDoes not affect l.
> (length ())

> (length)
length: expects 1 argument, given 0
> (length (list 'a 'b 'c))
> (define lists (list (list 'a 'b 'c) (list 1) (list 4 2 1 0)))
> lists
((a b c) (1) (4 2 1 0))
> (length lists)
> (length (car lists))
> (length 'a)
length: expects argument of type <proper list>; given a

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:03 2001.
This page may be found at
You may validate this page's HTML.
The source was last modified Sun Jan 28 12:30:14 2001.