Skip to content

linsert ​

Inserts elements into a list at a specified position.

Syntax ​

tcl
linsert list index ?value ...?

Parameters ​

  • list: The original list
  • index: Position to insert at. Supports:
    • Simple integer indices (0-based)
    • end keyword to insert at the end
    • end-N syntax for end-relative positioning
    • Negative indices are clamped to 0 (insert at beginning)
    • Indices greater than list length are treated as end
  • value: Values to insert (zero or more)

Examples ​

Insert at beginning ​

Output

Insert in middle ​

Output

Insert at end ​

Output

End-relative indexing ​

Output

Original list unchanged ​

Output

See Also ​