std-setnth | ![]() |
STD-SETNTH
replaces the i'th elementwith new. It is used to change certain elements only at a certain position in the list, often in conjunction with STD-POSITION
. It is not destructive, it always returns a copy. It is the counterpart of the function NTH
.
SUBST
will replace all matching elements by value, STD-SETNTH
only one at the given position.
STD-RPLACE
is the old depricated name, with reverse argument ordering.
If the index i is invalid (out of range), the original list is returned.
No error is signalled and no elements are added to the list!
;; change first
(std-setnth 'new 0 '(0 1 2)) => (NEW 1 2)
;; change last
(std-setnth 'new 2 '(0 1 2)) => (0 1 NEW)
;; no element added
(std-setnth 'new 3 '(0 1 2)) => (0 1 2)
new: any lisp expression.
i: an integer number. Should be between 0 and (1- (length lst)) to modify the list argument.
lst: any proper list.
A list.
None.
(std-require 'STDLIST)
Defined in STDLIST