join(3tcl)

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

πŸ’– join β€” bestie edition πŸ’–

okay so this is the join page from the Tcl Built-In Commands manual, and honestly? it's a little icon. it takes a list and smushes it into one string. that's it. that's the whole vibe. ✨


🌸 NAME 🌸

join β€” make a string by gluing list elements together 🫢


✨ SYNOPSIS ✨

join list ?joinString?

πŸ’… DESCRIPTION πŸ’…

so the list argument has to be a valid Tcl list β€” no cap, that's non-negotiable, it will simply not work otherwise πŸ’€

this command hands you back a string, and that string is made by joining all of the elements of list together, with joinString sitting between each adjacent pair of elements. like a little friendship bracelet where the string is the beads and the glue is the... okay the metaphor fell apart but you get me πŸŽ€

and the joinString argument? it defaults to a space character. so if you don't pass one, space is what you get. periodt. ⭐


πŸ¦‹ EXAMPLES πŸ¦‹

making a comma-separated list β€” the classic, the moment, the slay:

set data {1 2 3 4 5}
join $data ", "
     β†’ 1, 2, 3, 4, 5

using join to flatten a list by a single level β€” not me flattening my whole life πŸ™ˆ:

set data {1 {2 3} 4 {5 {6 7} 8}}
join $data
     β†’ 1 2 3 4 5 {6 7} 8

πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ KEYWORDS πŸ‘‘

element, join, list, separator


this page is brought to you by Tcl, and yes bestie, it lives at join(3tcl) in the Tcl Built-In Commands manual β€” go off, you're gonna use this constantly πŸŒˆπŸ’œ

πŸ“¦ where this page comes from