Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / share / tcl / help / tcl / lists / lreplace
1 NAME
2 lreplace - Replace elements in a list with new elements
3
4 SYNOPSIS
5 lreplace list first last ?element element ...?
6
7
8 DESCRIPTION
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
14 and last are ignored.
15
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
18 must exist.
19
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
23 before first.
24
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
30 of the list.
31
32 EXAMPLES
33 Replacing an element of a list with another:
34 % lreplace {a b c d e} 1 1 foo
35 a foo c d e
36
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
40
41 Deleting the last element from a list in a variable:
42 % set var {a b c d e}
43 a b c d e
44 % set var [lreplace $var end end]
45 a b c d
46
47
48 SEE ALSO
49 list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n),
50 lset(n), lrange(n), lsort(n)
51
52
53 KEYWORDS