lremove(n)
π lremove(n) β Tcl Built-In Commands π
okay bestie, welcome to the lremove page, it's a Tcl built-in and it is lowkey the cleanest little list surgery tool you'll ever meet β¨
β¨ NAME β¨
lremove β Remove elements from a list by index π
πΈ SYNOPSIS πΈ
lremove list ?index ...?
π¦ DESCRIPTION π¦
okay so here's the vibe: lremove gives you back a brand new list, made by taking out zero or more elements of list β all at the same time, at each of the indices you hand it as an arbitrary number of index arguments π
and the way it handles those indices?? iconic:
- the indices can be in any order you want, no sorting required, we're not doing that
- they can be repeated too, and ngl that's totally fine β if you name the same element twice, it only gets removed once. one and done. periodt.
- the index values get interpreted exactly the same way as index values for the command
string indexπ which means you get simple index arithmetic and indices relative to the end of the list, slay
quick reminder of the ground rules:
0refers to the first element of the listendrefers to the last element of the list
π EXAMPLES π
Removing the third element of a list (yes, index 2, we start at zero around here π«Ά):
% lremove {a b c d e} 2
a b d e
Removing two elements from a list (one counting from the back, one from the front, main character energy honestly):
% lremove {a b c d e} end-1 1
a c e
Removing the same element indicated in two different ways β look, 2 and end-2 are literally the same element here, and it still only disappears once π:
% lremove {a b c d e} 2 end-2
a b d e
π SEE ALSO π
list(n), lappend(n), lassign(n), ledit(n), lindex(n), linsert(n), llength(n), lmap(n), lpop(n), lrange(n), lrepeat(n), lreplace(n), lreverse(n), lsearch(n), lseq(n), lset(n), lsort(n)
π KEYWORDS π
element, list, remove
and that's the whole page, bestie!! π this one's from Tcl 9.0, and the page itself is lremove(n) β go forth and remove things responsibly, ily πβ¨π¦
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- Copyright (c) 2019 Donal K. Fellows
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms