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 lindex command can be used on the result to re-extract the original arguments πŸ‘‘
  • eval can 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 🧚:


⭐ 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