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.  If index has the value end, or if it is greater
21       than or equal to the number of elements in the list, then the new  ele‐
22       ments are appended to the list.  end-integer refers to the last element
23       in the list minus the specified integer offset.
24

EXAMPLE

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

SEE ALSO

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

KEYWORDS

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