What kind of a structure can the cdddr procedure be applied
to? What must its operand look like?
The operand must be a pair (pr1) in which the second component
is also a pair (pr2); moreover, the second component of
pr2 must also be a pair (pr3).
Which of the elements of such a structure does cdddr
return?
It returns the second component of pr3.
> (define example-1 (cons #f (cons #f (cons #f #t))))
> (cdddr example-1)
#t
> (define example-2 (cons (cons (cons 1 2) (cons 3 4))
(cons (cons 5 6) (cons 7 8))))
> (cdddr example-2)
8
What happens if the structure has the wrong shape? It is an error, so under most implementations the program crashes:
> (cdddr (cons (cons 1 2) (cons 3 4))) ERROR: cdddr: Wrong type in arg1 4
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/cdddr.html