What kind of a structure can the caar procedure be applied
to? What must its operand look like?
The operand must be a pair in which the first component is also a pair.
Which of the elements of such a structure does caar
return?
It returns the first component of the first component of its operand:
What happens if the structure has the wrong shape?> (define example-1 (cons (cons #t #f) #f)) > (caar example-1) #t > (define example-2 (cons (cons 1 2) (cons 3 4))) > (caar example-2) 1
It is an error, so under most implementations the program crashes:
> (caar (cons 1 (cons 2 3))) ERROR: caar: Wrong type in arg1 1
Next topic
Next major topic
Previous topic
Table of contents
This document is available on the World Wide Web as
http://www.math.grin.edu/~stone/scheme-web/caar.html