7.7
1.5 Pairs
(require rebellion/base/pair) | package: rebellion |
A pair is a container of two values. Pairs as defined by rebellion/base/pair are distinct from the pair datatype defined by racket/base, and are meant to be a drop-in replacement for them. Changes include:
car is spelled pair-first
cdr is spelled pair-second
(pair 1 2) writes as (pair 1 2) instead of (1 . 2)
Note that rebellion/base/pair provides a pair? predicate that conflicts with the one provided by racket/base.
Examples:
> (pair? (pair 1 2)) #t
> (list? (pair 1 2)) #f
> (require (only-in racket/base cons)) > (pair? (cons 1 2)) #f
Constructs a pair.
procedure
(pair-first p) → any/c
p : pair?
Returns the first value of p.
procedure
(pair-second p) → any/c
p : pair?
Returns the second value of p.