lappend
lappend is a built-in command in the Tcl programming language used to append one or more values to the end of a list stored in a variable or an array element. If the destination does not yet exist, lappend creates it as a list containing the provided values. The operation preserves list structure and appends the new items in the given order.
The command takes a destination name and one or more values: lappend destination value ?value ...?. The
set x 1; lappend x 2; # x becomes "1 2"
lappend x 3 4; # x becomes "1 2 3 4"
lappend arr(i) a; # arr(i) becomes "a" (or "existing a" if arr(i) already had content)
lappend arr(i) b c; # arr(i) becomes "a b c" (or with existing contents)
lappend is often used to build or modify lists incrementally while ensuring the result remains a valid