Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / share / tcl / help / tcl / lists / lrange
1 NAME
2 lrange - Return one or more adjacent elements from a list
3
4 SYNOPSIS
5 lrange list first last
6
7
8 DESCRIPTION
9 List must be a valid Tcl list. This command will return a new list
10 consisting of elements first through last, inclusive. First or last
11 may be end (or any abbreviation of it) to refer to the last element of
12 the list. If first is less than zero, it is treated as if it were
13 zero. If last is greater than or equal to the number of elements in
14 the list, then it is treated as if it were end. If first is greater
15 than last then an empty string is returned. Note: ``lrange list first
16 first'' does not always produce the same result as ``lindex list
17 first'' (although it often does for simple fields that aren't enclosed
18 in braces); it does, however, produce exactly the same results as
19 ``list [lindex list first]''
20
21 EXAMPLES
22 Selecting the first two elements:
23 % lrange {a b c d e} 0 1
24 a b
25
26 Selecting the last three elements:
27 % lrange {a b c d e} end-2 end
28 c d e
29
30 Selecting everything except the first and last element:
31 % lrange {a b c d e} 1 end-1
32 b c d
33
34 Selecting a single element with lrange is not the same as doing so with
35 lindex:
36 % set var {some {elements to} select}
37 some {elements to} select
38 % lindex $var 1
39 elements to
40 % lrange $var 1 1
41 {elements to}
42
43
44 SEE ALSO
45 list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n),
46 lset(n), lreplace(n), lsort(n)
47
48
49 KEYWORDS