summaryrefslogtreecommitdiffstats
path: root/doc/lindex.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lindex.n')
-rw-r--r--doc/lindex.n29
1 files changed, 24 insertions, 5 deletions
diff --git a/doc/lindex.n b/doc/lindex.n
index ac17d25..39682d9 100644
--- a/doc/lindex.n
+++ b/doc/lindex.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: lindex.n,v 1.18 2008/06/29 22:28:24 dkf Exp $
+'\" RCS: @(#) $Id: lindex.n,v 1.19 2008/07/06 09:42:58 dkf Exp $
'\"
.so man.macros
.TH lindex n 8.4 Tcl "Tcl Built-In Commands"
@@ -66,11 +66,9 @@ lindex [lindex [lindex $a 1] 2] 3
.CE
.SH EXAMPLES
.PP
+Lists can be indexed into from either end:
+.PP
.CS
-\fBlindex\fR {a b c}
- \fI\(-> a b c\fR
-\fBlindex\fR {a b c} {}
- \fI\(-> a b c\fR
\fBlindex\fR {a b c} 0
\fI\(-> a\fR
\fBlindex\fR {a b c} 2
@@ -79,6 +77,15 @@ lindex [lindex [lindex $a 1] 2] 3
\fI\(-> c\fR
\fBlindex\fR {a b c} end-1
\fI\(-> b\fR
+.CE
+.PP
+Lists or sequences of indices allow selection into lists of lists:
+.PP
+.CS
+\fBlindex\fR {a b c}
+ \fI\(-> a b c\fR
+\fBlindex\fR {a b c} {}
+ \fI\(-> a b c\fR
\fBlindex\fR {{a b c} {d e f} {g h i}} 2 1
\fI\(-> h\fR
\fBlindex\fR {{a b c} {d e f} {g h i}} {2 1}
@@ -88,6 +95,18 @@ lindex [lindex [lindex $a 1] 2] 3
\fBlindex\fR {{{a b} {c d}} {{e f} {g h}}} {1 1 0}
\fI\(-> g\fR
.CE
+.PP
+List indices may also perform limited computation, adding or subtracting fixed
+amounts from other indices:
+.PP
+.CS
+set idx 1
+\fBlindex\fR {a b c d e f} $idx+2
+ \fI\(-> d\fR
+set idx 3
+\fBlindex\fR {a b c d e f} $idx+2
+ \fI\(-> f\fR
+.CE
.SH "SEE ALSO"
list(n), lappend(n), linsert(n), llength(n), lsearch(n),
lset(n), lsort(n), lrange(n), lreplace(n),