Maybe a bit old, but wanted to clarify;
As already stated, the standard way to merge 2 lists is via concat
pre-v8.6. However please note that concat
gets very inefficient when dealing with long lists, since it analyzes the lists as part of the merge. eg when merging lists, the larger they get the slower they merge.
Both appends do not merge "lists", they just add to an existing list (lappend
) or variable (append
). Both appends have no impact to speed, since they do not analyze anything when appending.
If merging single entry list elements, one could merge them via set first [join [lappend first $second]]
but only if dealing with simple/single elements within each list (ie no spaces per element).
lappend first {*}$second
– Diapositiveforeach x $second { lappend first $x }
– Citronellaleval [linsert $second 0 lappend first]
– Diapositiveset l [concat a b \{ c]; llength $l
errors withunmatched open brace in list
– Janotconcat
should be smart enough to detect pure lists and avoid shimmering in this case, just literally concatenation them. In the example you cited neither of the arguments is a pure list, so the first stepconcat
does is to get list rep. of them, and fails to do this with the third one, obviously. Just replace\{
with[list \{]
and see it working. – Citronellalconcat
are indeed lists. – Citronellal