list(n)
β¨ list(n) β the Tcl built-in that makes lists β¨
okay bestie, welcome to list, one of the Tcl Built-In Commands, and honestly? she's a baddie. π
π NAME π
list β Create a list π
π¦ SYNOPSIS π¦
list ?arg arg ...?
πΈ DESCRIPTION πΈ
So like, here's the tea π: this command returns a list made up of all the args, or β and this is important β an empty string if you don't give it any args at all. No args? No list content. Periodt.
Now, the β¨magicβ¨ part: braces and backslashes get added as necessary, so that:
- the
lindexcommand can be used on the result to re-extract the original arguments π evalcan also be used to execute the resulting list, with arg1 comprising the command's name and the other args comprising its arguments π₯
not me being obsessed with how much heavy lifting those auto-added braces do π
And here's the plot twist, because people always ask: list produces slightly different results than concat. Why? Because concat removes one level of grouping before forming the list, while list works directly from the original arguments. Same vibe, different behavior. iykyk π
π EXAMPLE π
okay so watch this. the command:
list a b "c d e " " f {g h}"
will return:
a b {c d e } { f {g h}}
meanwhile concat with the same exact arguments will return:
a b c d e f {g h}
see?? the grouping level just poof gone. concat ate that one layer and left no crumbs π«Ά
π SEE ALSO π
your girl does not work alone, she's got a whole friend group π§:
lappend(n)lassign(n)ledit(n)lindex(n)linsert(n)llength(n)lmap(n)lpop(n)lrange(n)lremove(n)lrepeat(n)lreplace(n)lreverse(n)lsearch(n)lseq(n)lset(n)lsort(n)
β KEYWORDS β
- element
- list
- quoting
and that's the whole page bestie!! π this one came from the Tcl manual, page list(n) β sending you the biggest π and reminding you that this whole vibe check was brought to you by Tcl. slay, go make some lists, and remember: braces are added as necessary, no cap π¦β¨
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- Copyright (c) 1993 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- Copyright (c) 2001 Kevin B. Kenny <kennykb@acm.org>. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms