concat(3tcl)
π concat β the Tcl built-in that's literally just "glue lists together" π
okay bestie, welcome to concat(3tcl), one of the Tcl Built-In Commands, and ngl she's lowkey one of the most underrated icons in the whole toolkit π«Ά
β¨ SYNOPSIS β¨
concat ?arg arg ...?
πΈ DESCRIPTION πΈ
So here's the tea, bestie: this command takes each of its arguments and joins them together with spaces, after trimming leading and trailing white-space from each of them. Periodt. βοΈ
And if all of the arguments happen to be lists? Then it's giving the exact same energy as concatenating them into a single list. No cap. π
Arguments that are empty (after trimming, obvs) get ignored entirely β like, they're not even invited to the function. π
It permits any number of arguments, she's flexible like that π . And if you supply no args at all? The result is an empty string. That's it, that's the whole vibe.
π¦ EXAMPLES π¦
Okay so even though concat will concatenate lists and flatten them in the process (so giving the following interactive session):
% concat a b {c d e} {f {g h}}
a b c d e f {g h}
...it will also concatenate things that are not lists, as can be seen from this session:
% concat " a b {c " d " e} f"
a b {c d e} f
Note also that the concatenation does not remove spaces from the middle of values, as can be seen here:
% 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, she said what she said)
π so when do I actually want real list concatenation tho?
For true list concatenation, the list command should be used with expansion of each input list:
% list {*}"a b c" {*}{ d e f }
a b c d e f
see how the extra spaces got ate?? list + {*} is the moment, fr fr π₯
π SEE ALSO π
β KEYWORDS β
concatenate, join, list
and that's the whole page bestie!! this one came straight out of Tcl 8.3 and it's dated right there in the concat(3tcl) footer, so if you're running something ancient or something brand new, now you know where she came from π§ mwah, go flatten some lists, you've got this πβ¨π
π¦ where this page comes from
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 1993 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms