Since pairs can contain other pairs, you could build large data structures out of pairs. Are there any other procedures for recovering parts of such data structures?
Yes, twenty-eight others in all:
caar
cadr
cdar
cddr
caaar
caadr
cadar
caddr
cdaar
cdadr
cddar
cdddr
caaaar
caaadr
caadar
caaddr
cadaar
cadadr
caddar
cadddr
cdaaar
cdaadr
cdadar
cdaddr
cddaar
cddadr
cdddar
cddddr
c and the
final r are a mnemonic for the sequence of nested calls to
car and cdr that would be needed to bring out the
same element -- for instance, (caaddr pr) yields the same
result as (car (car (cdr (cdr pr)))). Do I really have to read about every one of these?
For convenience of reference, I've included a page about each one. But reading them all would be too much like traversing a maze of twisty little passages, each one slightly different. You might look at a couple; as soon as you get the idea, follow the ``Next major topic'' link.
caar and other access procedures
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/cxr.html