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.   First  or  last
18       may  be end (or any abbreviation of it) to refer to the last element of
19       the list.  If first is less than zero, it is  treated  as  if  it  were
20       zero.   If  last  is greater than or equal to the number of elements in
21       the list, then it is treated as if it were end.  If  first  is  greater
22       than  last then an empty string is returned.  Note: ``lrange list first
23       first'' does not always  produce  the  same  result  as  ``lindex  list
24       first''  (although it often does for simple fields that aren't enclosed
25       in braces); it does, however,  produce  exactly  the  same  results  as
26       ``list [lindex list first]''
27

EXAMPLES

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

SEE ALSO

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

KEYWORDS

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