| list-copy(3scm) | Scheme Programmer's Manual | list-copy(3scm) |
NAME
list-copy - copy a list
LIBRARY
(import (scheme base)) ;R7RS
SYNOPSIS
(list-copy obj)
DESCRIPTION
Returns a newly allocated copy of the given obj if it is a list. Only the pairs themselves are copied; the cars of the result are the same (in the sense of eqv?(3scm)) as the cars of list. If obj is an improper list, so is the result, and the final cdrs are the same in the sense of eqv?(3scm). An obj which is not a list is returned unchanged.
RETURN VALUES
Returns a single value
EXAMPLES
(define a '(1 8 2 8)) ; a may be immutable (define b (list-copy a)) (set-car! b 3) ; b is mutable b => (3 8 2 8) a => (1 8 2 8)
COMPATIBILITY
This procedure is unique to R6RS. An alternative is to write (map values obj).
ERRORS
It is an error if the wrong number of arguments was passed or an argument was outside its domain. It is an error if obj is a circular list. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.
SEE ALSO
map(3scm), vector-copy(3scm)
STANDARDS
R7RS
HISTORY
This procedure is new in 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://weinholt.se/scheme/manpages/.
| 2023-08-13 |