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