list(3tcl)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– list β€” the Tcl built-in manual, but make it cute πŸ’–

okay bestie, gather round, we're talking about list from Tcl Built-In Commands and honestly? she's the moment. 🌸


✨ NAME ✨

list β€” Create a list πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

list ?arg arg ...?

πŸ’… DESCRIPTION πŸ’…

okay so here's the tea: this command returns a list made up of all the args, or, if you pass no args at all, it hands you back an empty string. nothing. a void. a clean slate. 🫢

and here's the part that's giving genius: braces and backslashes get added in wherever they're needed, so that:

  • lindex can be used on the result to re-extract the original arguments β€” like, it'll literally reconstruct them for you, no cap ✨
  • and also so that eval can be used to execute the resulting list, with arg1 comprising the command's name and the other args comprising its arguments πŸ”₯

now, lowkey important comparison moment: list produces slightly different results than concat. the difference? concat removes one level of grouping before forming the list, while list works directly from the original arguments. that's it, that's the whole vibe shift. πŸ’€


🌈 EXAMPLE 🌈

the command

list a b "c d e  " "  f {g h}"

will return

a b {c d e  } {  f {g h}}

while concat with the same arguments will return

a b c d e f {g h}

see?? she preserved those spaces and braces. iconic behaviour. periodt. πŸ‘‘


🧚 SEE ALSO 🧚

the whole list-adjacent friend group, fr fr πŸ’œ


πŸ”‘ KEYWORDS πŸ”‘

element, list, quoting ⭐


and that's the page!! πŸŽ€ brought to you by the Tcl crew, list(3tcl), iykyk β€” go forth and build your lists, bestie, you're gonna slay πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from