📄 lindex.n
字号:
'\"'\" Copyright (c) 1993 The Regents of the University of California.'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.'\" Copyright (c) 2001 by Kevin B. Kenny. All rights reserved.'\"'\" 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.7 2001/11/14 23:15:33 hobbs Exp $'\" .so man.macros.TH lindex n 8.4 Tcl "Tcl Built-In Commands".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMElindex \- Retrieve an element from a list.SH SYNOPSIS\fBlindex \fIlist ?index...?\fR.BE.SH DESCRIPTION.PP.VS 8.4The \fBlindex\fP command accepts a parameter, \fIlist\fP, whichit treats as a Tcl list. It also accepts zero or more \fIindices\fP intothe list. The indices may be presented either consecutively on thecommand line, or grouped in aTcl list and presented as a single argument..PPIf no indices are presented, the command takes the form:.CSlindex list.CEor.CSlindex list {}.CEIn this case, the return value of \fBlindex\fR is simply the value of the\fIlist\fR parameter..PPWhen presented with a single index, the \fBlindex\fR commandtreats \fIlist\fR as a Tcl list and returns the.VE\fIindex\fR'th element from it (0 refers to the first element of the list).In extracting the element, \fBlindex\fR observes the same rulesconcerning braces and quotes and backslashes as the Tcl commandinterpreter; however, variablesubstitution and command substitution do not occur.If \fIindex\fR is negative or greater than or equal to the numberof elements in \fIvalue\fR, then an emptystring is returned.If \fIindex\fR has the value \fBend\fR, it refers to the last elementin the list, and \fBend\-\fIinteger\fR refers to the last element inthe list minus the specified integer offset..PP.VS 8.4If additional \fIindex\fR arguments are supplied, then each argument isused in turn to select an element from the previous indexing operation,allowing the script to select elements from sublists. The command,.CSlindex $a 1 2 3.CEor.CSlindex $a {1 2 3}.CEis synonymous with.CSlindex [lindex [lindex $a 1] 2] 3.CE.SH EXAMPLES.CSlindex {a b c} => a b clindex {a b c} {} => a b clindex {a b c} 0 => alindex {a b c} 2 => clindex {a b c} end => clindex {a b c} end-1 => blindex {{a b c} {d e f} {g h i}} 2 1 => hlindex {{a b c} {d e f} {g h i}} {2 1} => hlindex {{{a b} {c d}} {{e f} {g h}}} 1 1 0 => glindex {{{a b} {c d}} {{e f} {g h}}} {1 1 0} => g.CE.VE.SH "SEE ALSO"list(n), lappend(n), linsert(n), llength(n), lsearch(n), .VS 8.4lset(n),.VElsort(n),lrange(n), lreplace(n).SH KEYWORDSelement, index, list
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -