join(n)
β¨ join(n) β Tcl Built-In Commands β¨
okay bestie, welcome to the join page from the Tcl Built-In Commands manual π this one's short, it's sweet, it's a total baddie, and you're gonna be obsessed.
π NAME π
join β create a string by joining together list elements π«Ά
πΈ SYNOPSIS πΈ
join list ?joinString?
π DESCRIPTION π
okay so. the list argument must be a valid Tcl list β like, that's not optional, that's the vibe check it has to pass π
this command returns the string you get by joining all of the elements of list together, with joinString sitting between each adjacent pair of elements. think of it as the glue, the ribbon, the little separator doing the most between your faves π
and the joinString argument? it defaults to a space character. so if you don't hand it one, it just quietly puts spaces in there. lowkey iconic behavior honestly.
π¦ EXAMPLES π¦
making a comma-separated list, because who doesn't love that:
set data {1 2 3 4 5}
join $data ", "
β 1, 2, 3, 4, 5
using join to flatten a list by a single level β one level only, don't get carried away:
set data {1 {2 3} 4 {5 {6 7} 8}}
join $data
β 1 2 3 4 5 {6 7} 8
see how {6 7} stayed all bundled up? yeah. single level. periodt π
π SEE ALSO π
π KEYWORDS π
element, join, list, separator
that's the whole page bestie, no cap, it really is that simple π
this little cutie lives in the Tcl manual as join(n) β go forth and join things, you got this πβ¨π¦ππΈπ«Ά
π¦ 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
- nixpkgs unstable: tcl 9.1.0
- 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