2 lreplace - Replace elements in a list with new elements
5 lreplace list first last ?element element ...?
9 lreplace returns a new list formed by replacing one or more elements of
10 list with the element arguments. first and last specify the first and
11 last index of the range of elements to replace. 0 refers to the first
12 element of the list, and end (or any abbreviation of it) may be used to
13 refer to the last element of the list. If list is empty, then first
16 If first is less than zero, it is considered to refer to the first ele-
17 ment of the list. For non-empty lists, the element indicated by first
20 If last is less than zero but greater than first, then any specified
21 elements will be prepended to the list. If last is less than first
22 then no elements are deleted; the new elements are simply inserted
25 The element arguments specify zero or more new arguments to be added to
26 the list in place of those that were deleted. Each element argument
27 will become a separate element of the list. If no element arguments
28 are specified, then the elements between first and last are simply
29 deleted. If list is empty, any element arguments are added to the end
33 Replacing an element of a list with another:
34 % lreplace {a b c d e} 1 1 foo
37 Replacing two elements of a list with three:
38 % lreplace {a b c d e} 1 2 three more elements
39 a three more elements d e
41 Deleting the last element from a list in a variable:
44 % set var [lreplace $var end end]
49 list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n),
50 lset(n), lrange(n), lsort(n)