1lrange(n)                    Tcl Built-In Commands                   lrange(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       lrange - Return one or more adjacent elements from a list
9

SYNOPSIS

11       lrange list first last
12_________________________________________________________________
13
14

DESCRIPTION

16       List  must  be  a  valid Tcl list.  This command will return a new list
17       consisting of elements first through last, inclusive.  The index values │
18       first and last are interpreted the same as index values for the command │
19       string index, supporting simple index arithmetic and  indices  relative │
20       to  the  end of the list.  If first is less than zero, it is treated as
21       if it were zero.  If last is greater than or equal  to  the  number  of
22       elements  in  the list, then it is treated as if it were end.  If first
23       is greater than last then an empty string is returned.   Note:  “lrange
24       list  first  first”  does not always produce the same result as “lindex
25       list first” (although it often does for  simple  fields  that  are  not
26       enclosed in braces); it does, however, produce exactly the same results
27       as “list [lindex list first]
28

EXAMPLES

30       Selecting the first two elements:
31              % lrange {a b c d e} 0 1
32              a b
33
34       Selecting the last three elements:
35              % lrange {a b c d e} end-2 end
36              c d e
37
38       Selecting everything except the first and last element:
39              % lrange {a b c d e} 1 end-1
40              b c d
41
42       Selecting a single element with lrange is not the same as doing so with
43       lindex:
44              % set var {some {elements to} select}
45              some {elements to} select
46              % lindex $var 1
47              elements to
48              % lrange $var 1 1
49              {elements to}
50
51

SEE ALSO

53       list(n),  lappend(n),  lindex(n),  linsert(n),  llength(n), lsearch(n),
54       lset(n), lreplace(n), lsort(n), string(n)                               │
55
56

KEYWORDS

58       element, list, range, sublist
59
60
61
62Tcl                                   7.4                            lrange(n)
Impressum