OS Manuals

llength(n)

llength - Count the number of elements in a list

llength(n) Tcl Built-In Commands llength(n)


llength - Count the number of elements in a list

llength list


Treats list as a list and returns a decimal string giving the number of elements in it.

The result is the number of elements:

% llength {a b c d e}
5
% llength {a b c}
3
% llength {}
0

Elements are not guaranteed to be exactly words in a dictionary sense of course, especially when quoting is used:

% llength {a b {c d} e}
4
% llength {a b { } c d e}
6

An empty list is not necessarily an empty string:

% set var { }; puts "[string length $var],[llength $var]"
1,0

list(n), lappend(n), lassign(n), ledit(n), lindex(n), linsert(n), lmap(n), lpop(n), lrange(n), lremove(n), lrepeat(n), lreplace(n), lreverse(n), lsearch(n), lseq(n), lset(n), lsort(n)

element, list, length

Tcl

tcl 9.1.0-r1 · os · ingested 2026-10-26