list-set! - modify an element in a list
(import (scheme base)) ;R7RS
Stores obj in element k of list.
Returns an unspecified value.
(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
This procedure was added in R7RS to round out the sequence operations.
This procedure is unique to R7RS. An alternative is to use set-car!(3scm)
and list-tail(3scm).
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.
This procedure first appeared in R7RS.