concat(n)

πŸ“¦
version 9.0.3 Β· 3 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– concat(n) πŸ’–

ok so bestie, welcome to concat β€” it's a built-in command from the Tcl Built-In Commands manual, and it's literally the glue stick of Tcl. ✨


🌸 NAME 🌸

concat β€” join lists together 🫢


✨ SYNOPSIS ✨

concat ?arg arg ...?

πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the vibe: this command takes each of its arguments and joins them all together with spaces, but first it trims the leading and trailing white-space off of every single one of them. 🧹✨

and like β€” if all of the arguments are lists, then this has the exact same effect as concatenating them into one single list. no cap. πŸ’…

arguments that end up empty (like, after the trimming happens) are just ignored entirely. they don't get a seat at the table, they're not invited, bye. πŸ™ˆ

it permits any number of arguments, bestie β€” zero, one, a hundred, whatever. and if you supply no args at all, the result is just an empty string. that's it. that's the whole thing. 🌈


πŸ”₯ EXAMPLES πŸ”₯

so even though concat will concatenate lists and flatten them in the process, like in this little interactive session right here:

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

...it will also concatenate stuff that isn't even a list, which you can see from this next session:

% concat " a b {c   " d "  e} f"
a b {c d e} f

and note β€” note this, fr fr β€” the concatenation does not remove spaces from the middle of values. look:

% concat "a   b   c" { d e f }
a   b   c d e f

(i.e., there are three spaces between each of the a, the b and the c. yes really. count them. 🫣)

so if you want true list concatenation, you should use the list command with expansion of each input list:

% list {*}"a   b   c" {*}{ d e f }
a b c d e f

see?? that one actually collapsed the spaces. main character behavior. πŸ‘‘


🌈 SEE ALSO 🌈


⭐ KEYWORDS ⭐

concatenate, join, list


ok that's the whole page bestie!! this one's from the <strong>Tcl 8.3</strong> era, dated way back, and it's filed under the <strong>concat(n)</strong> page in the Tcl manual set. go forth and glue your lists together πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from