| 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 <[email protected]>. 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 |
.TH llength n "" Tcl "Tcl Built-In Commands" |
| 10 |
.so man.macros |
| 11 |
.BS |
| 12 |
'\" Note: do not modify the .SH NAME line immediately below! |
| 13 |
.SH NAME |
| 14 |
llength \- Count the number of elements in a list |
| 15 |
.SH SYNOPSIS |
| 16 |
\fBllength \fIlist\fR |
| 17 |
.BE |
| 18 |
.SH DESCRIPTION |
| 19 |
.PP |
| 20 |
Treats \fIlist\fR as a list and returns a decimal string giving |
| 21 |
the number of elements in it. |
| 22 |
.SH EXAMPLES |
| 23 |
.PP |
| 24 |
The result is the number of elements: |
| 25 |
.PP |
| 26 |
.CS |
| 27 |
% \fBllength\fR {a b c d e} |
| 28 |
5 |
| 29 |
% \fBllength\fR {a b c} |
| 30 |
3 |
| 31 |
% \fBllength\fR {} |
| 32 |
0 |
| 33 |
.CE |
| 34 |
.PP |
| 35 |
Elements are not guaranteed to be exactly words in a dictionary sense |
| 36 |
of course, especially when quoting is used: |
| 37 |
.PP |
| 38 |
.CS |
| 39 |
% \fBllength\fR {a b {c d} e} |
| 40 |
4 |
| 41 |
% \fBllength\fR {a b { } c d e} |
| 42 |
6 |
| 43 |
.CE |
| 44 |
.PP |
| 45 |
An empty list is not necessarily an empty string: |
| 46 |
.PP |
| 47 |
.CS |
| 48 |
% set var { }; puts "[string length $var],[\fBllength\fR $var]" |
| 49 |
1,0 |
| 50 |
.CE |
| 51 |
.SH "SEE ALSO" |
| 52 |
list(n), lappend(n), lindex(n), linsert(n), lsearch(n), |
| 53 |
lset(n), lsort(n), lrange(n), lreplace(n) |
| 54 |
.SH KEYWORDS |
| 55 |
element, list, length |