## LIBRARY

```(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme cxr))               ;R7RS
```

## SYNOPSIS

```(caaar pair)
(caaar pair)
(caadr pair)
(cadar pair)
(caddr pair)
(cdaar pair)
(cdadr pair)
(cddar pair)
(cdddr pair)
(caaaar pair)
(caaadr pair)
(caadar pair)
(caaddr pair)
(cadaar pair)
(cadadr pair)
(caddar pair)
(cadddr pair)
(cdaaar pair)
(cdaadr pair)
(cdadar pair)
(cdaddr pair)
(cddaar pair)
(cddadr pair)
(cdddar pair)
(cddddr pair)
```

## DESCRIPTION

These twenty-four procedures are further compositions of car and cdr on the same principles as caar(3scm). For example, caddr could be defined by

```  (define caddr (lambda (x) (car (cdr (cdr x))))).
```

Arbitrary compositions up to four deep are provided.

## RETURN VALUES

Returns the contents of the car or cdr field of the pair which is the next to last pair through the chain of pairs.

## EXAMPLES

```(cadar '(((a . b) . (c . d)) ((1 . 2) . (3 . 4)))) => c
(cddddr '(1 2 3 4 5 6))                            => (5 6)
```

## APPLICATION USAGE

These compositions are increasingly harder to read and reason about. It is a good idea to instead use a pattern matching library like (chibi match).

## ERRORS

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed, the argument was not a pair or one of the intermediate links of car and cdr fields was not a pair.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

caar(3scm)

## STANDARDS

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

## AUTHORS

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at `https://github.com/schemedoc/manpages/`.

Markup created by unroff 1.0sc,    March 04, 2023.