The Grinnell Scheme Web: The cddr
procedure

What kind of a structure can the cddr procedure be applied to? What must its operand look like?

The operand must be a pair in which the second component is also a pair.

Which of the elements of such a structure does cddr return?

It returns the second component of the second component of its operand:

> (define example-1 (cons #f (cons #f #t)))
> (cddr example-1)
#t
> (define example-2 (cons (cons 1 2) (cons 3 4)))
> (cddr example-2)
4
What happens if the structure has the wrong shape?

It is an error, so under most implementations the program crashes:

> (cddr (cons (cons 1 2) 3))

ERROR: cddr: Wrong type in arg1 3


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/cddr.html


created August 5, 1995
last revised December 26, 1995

Copyright 1995 by John David Stone (stone@math.grin.edu)