cons* - cons up a chain of pairs
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs lists)) ;R6RS
SYNOPSIS
(cons* obj1 ... objn obj)
(cons* obj)
DESCRIPTION
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.
RETURN VALUES
Returns a single value, which is either
obj
itself or a chain of pairs.
EXAMPLES
(cons* 1 2 '(3 4 5)) => (1 2 3 4 5)
(cons* 1 2 3) => (1 2 . 3)
(cons* 1) => 1
APPLICATION USAGE
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(7scm)
for constructs like
`(,a ,b ,@x*).
COMPATIBILITY
This procedure is unique to R6RS.
ERRORS
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.
SEE ALSO
list(3scm),
cons(3scm)
STANDARDS
R6RS
HISTORY
The first RnRS report to have this procedure was R6RS.
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.