1linsert(n)                   Tcl Built-In Commands                  linsert(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       linsert - Insert elements into a list
9

SYNOPSIS

11       linsert list index element ?element element ...?
12_________________________________________________________________
13
14

DESCRIPTION

16       This command produces a new list from list by inserting all of the ele‐
17       ment arguments just before the index'th element of list.  Each  element
18       argument  will  become a separate element of the new list.  If index is
19       less than or equal to zero, then the new elements are inserted  at  the
20       beginning  of  the  list.  The interpretation of the index value is the │
21       same as for the command string index, supporting  simple  index  arith‐ │
22       metic and indices relative to the end of the list.
23

EXAMPLE

25       Putting some values into a list, first indexing from the start and then
26       indexing from the end, and then chaining them together:
27              set oldList {the fox jumps over the dog}
28              set midList [linsert $oldList 1 quick]
29              set newList [linsert $midList end-1 lazy]
30              # The old lists still exist though...
31              set newerList [linsert [linsert $oldList end-1 quick] 1 lazy]
32
33

SEE ALSO

35       list(n),  lappend(n),  lindex(n),  llength(n),   lsearch(n),   lset(n),
36       lsort(n), lrange(n), lreplace(n), string(n)                             │
37
38

KEYWORDS

40       element, insert, list
41
42
43
44Tcl                                   8.2                           linsert(n)
Impressum