| list-set!(3scm) | Scheme Programmer's Manual | list-set!(3scm) |
NAME
list-set! - modify an element in a list
LIBRARY
(import (scheme base)) ;R7RS
SYNOPSIS
(list-set! list k obj)
DESCRIPTION
Stores obj in element k of list.
RETURN VALUES
Returns an unspecified value.
EXAMPLES
(let ((ls (list 'one 'two 'five!)))
(list-set! ls 2 'three)
ls)
=> (one two three)
(list-set! '(0 1 2) 1 "oops")
error ; constant list should not be mutated
RATIONALE
This procedure was added in R7RS to round out the sequence operations.
COMPATIBILITY
This procedure is unique to R7RS. An alternative is to use set-car!(3scm) and list-tail(3scm).
ERRORS
It is an error if the wrong number of arguments was passed or an argument was outside its domain. In particular, it is an error if k is not a valid index of list. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.
SEE ALSO
set-car!(3scm)
STANDARDS
R7RS
HISTORY
This procedure first appeared 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 |