linsert - insert [element]s into a list http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/linsert.htm ---- linsert list index element1 ?element2 element3 ...? ---- A user asked why linsert $list 0 .. did not result in .. being inserted into list. Jesper Blommaskog (d9jesper@dtek.chalmers.se) replied: When doing list operations other than lappend, you must save the returned value. This applies to list, lindex, lrange, and lreplace at least. In this example, you would perhaps want to do something like: set list [ linsert $list 0 .. ] ---- [TFW] Feb 20, 2004 - Inplace inserts Often time we have a long list we want to insert "in-place", that is without copying the list to a new altered list. Using the K combinator it is quite easy. proc lipinsert {_list index args} { upvar $_list list set list [eval [list linsert [K $list [set list ""]] $index] $args] } > set A [list 1 2 3] 1 2 3 > lipinsert A 1 a b c 1 a b c 2 3 ---- See also [list], [lappend], [llength], [lrange], [lreplace], [lsearch], [lsort] . ---- [Tcl syntax help] - [Arts and crafts of Tcl-Tk programming] - [Category Command]