diff options
Diffstat (limited to 'doc/lrange.n')
-rw-r--r-- | doc/lrange.n | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/doc/lrange.n b/doc/lrange.n index 34f0150..4f4816a 100644 --- a/doc/lrange.n +++ b/doc/lrange.n @@ -15,18 +15,15 @@ lrange \- Return one or more adjacent elements from a list .SH SYNOPSIS \fBlrange \fIlist first last\fR .BE - .SH DESCRIPTION .PP \fIList\fR must be a valid Tcl list. This command will return a new list consisting of elements \fIfirst\fR through \fIlast\fR, inclusive. -.VS 8.5 The index values \fIfirst\fR and \fIlast\fR are interpreted the same as index values for the command \fBstring index\fR, supporting simple index arithmetic and indices relative to the end of the list. -.VE If \fIfirst\fR is less than zero, it is treated as if it were zero. If \fIlast\fR is greater than or equal to the number of elements in the list, then it is treated as if it were \fBend\fR. @@ -40,19 +37,23 @@ does not always produce the same result as braces); it does, however, produce exactly the same results as .QW "\fBlist [lindex \fIlist first\fB]\fR" .SH EXAMPLES +.PP Selecting the first two elements: +.PP .CS % \fBlrange\fR {a b c d e} 0 1 a b .CE .PP Selecting the last three elements: +.PP .CS % \fBlrange\fR {a b c d e} end-2 end c d e .CE .PP Selecting everything except the first and last element: +.PP .CS % \fBlrange\fR {a b c d e} 1 end-1 b c d @@ -60,6 +61,7 @@ b c d .PP Selecting a single element with \fBlrange\fR is not the same as doing so with \fBlindex\fR: +.PP .CS % set var {some {elements to} select} some {elements to} select @@ -68,13 +70,9 @@ elements to % \fBlrange\fR $var 1 1 {elements to} .CE - .SH "SEE ALSO" list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n), lset(n), lreplace(n), lsort(n), -.VS 8.5 string(n) -.VE - .SH KEYWORDS element, list, range, sublist |