How do you recover the second component of a pair?
Use the cdr procedure:
The> (define pr (cons 1 2)) #> (cdr pr) 2 > (cdr (cons 66 81)) 81 > (cdr (cons 1 (cons (cons 2 3) 4))) ((2 . 3) . 4)
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