The Grinnell Scheme Web: The cdr procedure

How do you recover the second component of a pair?

Use the cdr procedure:

> (define pr (cons 1 2))
#
> (cdr pr)
2
> (cdr (cons 66 81))
81
> (cdr (cons 1 (cons (cons 2 3) 4)))
((2 . 3) . 4)
The car procedure is of arity 1 and can be applied only to a pair; giving it an operand of any other type is an error.
> (cdr 54)

ERROR: cdr: Wrong type in arg1 54


Next topic
Previous topic
Table of contents


This document is available on the World Wide Web as

http://www.math.grin.edu/~stone/scheme-web/cdr.html


created August 5, 1995
last revised December 26, 1995

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