llength(3tcl)

๐Ÿ“ฆ
version 9.0.4 ยท 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’– llength โ€” the Tcl Built-In Commands glow-up ๐Ÿ’–

okay bestie, gather round, because today we're talking about llength from the Tcl Built-In Commands crew, and honestly? she's a whole vibe. โœจ


โœจ NAME โœจ

llength โ€” count the number of elements in a list ๐Ÿงฎ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

llength list

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So here's the tea: you hand her a list, she treats it like a list (obviously, she's not gonna argue with you about it), and she hands you back a decimal string โ€” that's the number of elements chilling inside it. That's it. That's the whole job. And she does it flawlessly, no cap. ๐Ÿ‘‘


๐ŸŽ€ EXAMPLES ๐ŸŽ€

first up, the basics: the result is literally just the number of elements. iconic behaviour.

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

now listen, elements are not guaranteed to be exactly words in the dictionary sense of things โ€” obviously, especially once quoting enters the chat. it's giving "a word is whatever the list parser says it is" ๐Ÿ™ˆ

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

and here's the plot twist that gets people every single time: an empty list is not necessarily an empty string. those two are NOT the same bestie, don't let anyone tell you otherwise ๐Ÿ˜ญ

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

look at that. string length says 1, llength says 0. two different numbers, two different questions. she contains multitudes. ๐Ÿ’€โœจ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

the whole friend group, because they run deep and they run together ๐Ÿซถ


๐Ÿ”‘ KEYWORDS ๐Ÿ”‘

element, list, length โ€” the trio. the holy trinity. the main character energy. โญ


and that's the whole page, bestie!! ๐Ÿ’– this one comes to you straight from Tcl, filed under llength(3tcl), and she's been serving reliable list-counting realness since forever. go forth and count ur elements, you absolute legend ๐Ÿ‘‘๐ŸŒธ๐Ÿฆ‹๐Ÿ’…

๐Ÿ“ฆ where this page comes from