Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/lrange.n @ 33

Last change on this file since 33 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 2.2 KB
Line 
1'\"
2'\" Copyright (c) 1993 The Regents of the University of California.
3'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4'\" Copyright (c) 2001 Kevin B. Kenny <kennykb@acm.org>.  All rights reserved.
5'\"
6'\" See the file "license.terms" for information on usage and redistribution
7'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8'\"
9'\" RCS: @(#) $Id: lrange.n,v 1.17 2008/03/26 09:59:22 dkf Exp $
10'\"
11.so man.macros
12.TH lrange n 7.4 Tcl "Tcl Built-In Commands"
13.BS
14'\" Note:  do not modify the .SH NAME line immediately below!
15.SH NAME
16lrange \- Return one or more adjacent elements from a list
17.SH SYNOPSIS
18\fBlrange \fIlist first last\fR
19.BE
20
21.SH DESCRIPTION
22.PP
23\fIList\fR must be a valid Tcl list.  This command will
24return a new list consisting of elements
25\fIfirst\fR through \fIlast\fR, inclusive.
26.VS 8.5
27The index values \fIfirst\fR and \fIlast\fR are interpreted
28the same as index values for the command \fBstring index\fR,
29supporting simple index arithmetic and indices relative to the
30end of the list.
31.VE
32If \fIfirst\fR is less than zero, it is treated as if it were zero.
33If \fIlast\fR is greater than or equal to the number of elements
34in the list, then it is treated as if it were \fBend\fR.
35If \fIfirst\fR is greater than \fIlast\fR then an empty string
36is returned.
37Note:
38.QW "\fBlrange \fIlist first first\fR"
39does not always produce the same result as
40.QW "\fBlindex \fIlist first\fR"
41(although it often does for simple fields that are not enclosed in
42braces); it does, however, produce exactly the same results as
43.QW "\fBlist [lindex \fIlist first\fB]\fR"
44.SH EXAMPLES
45Selecting the first two elements:
46.CS
47% \fBlrange\fR {a b c d e} 0 1
48a b
49.CE
50.PP
51Selecting the last three elements:
52.CS
53% \fBlrange\fR {a b c d e} end-2 end
54c d e
55.CE
56.PP
57Selecting everything except the first and last element:
58.CS
59% \fBlrange\fR {a b c d e} 1 end-1
60b c d
61.CE
62.PP
63Selecting a single element with \fBlrange\fR is not the same as doing
64so with \fBlindex\fR:
65.CS
66% set var {some {elements to} select}
67some {elements to} select
68% lindex $var 1
69elements to
70% \fBlrange\fR $var 1 1
71{elements to}
72.CE
73
74.SH "SEE ALSO"
75list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n),
76lset(n), lreplace(n), lsort(n),
77.VS 8.5
78string(n)
79.VE
80
81.SH KEYWORDS
82element, list, range, sublist
Note: See TracBrowser for help on using the repository browser.