cons* - cons up a chain of pairs
(import (rnrs)) ;R6RS
(import (rnrs lists)) ;R6RS
(cons* obj1 ... objn obj)
(cons* obj)
If called with at least two arguments, cons* returns a freshly allocated
chain of pairs whose cars are obj1, ..., objn, and whose last
cdr is obj. If called with only one argument, cons* returns that
argument.
This procedure is similar to list(3scm), with the
difference that the last argument (rather than the empty list) becomes the
cdr of last pair in the chain.
Returns a single value, which is either obj itself or a chain of pairs.
(cons* 1 2 '(3 4 5)) => (1 2 3 4 5)
(cons* 1 2 3) => (1 2 . 3)
(cons* 1) => 1
This procedure replaces constructs like (apply list a b x*). It is faster
and handles the case where the last argument does not need to be a list.
Depending on the Scheme implementation, it may also be used in the expansion
of quasiquote(3scm) for constructs like `(,a ,b ,@x*).
This procedure is unique to R6RS.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
- The wrong number of arguments was passed.
- &implementation-restriction (R6RS)
- There is not enough free memory to hold the new pairs.
The first RnRS report to have this procedure was R6RS.