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

DESCRIPTION

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

EXAMPLES

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

SEE ALSO

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

KEYWORDS

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