lremove(3tcl)
β¨ NAME β¨
lremove β bestie's fave way to yeet elements out of a list by index π
πΈ SYNOPSIS πΈ
lremove list ?index ...?
π¦ DESCRIPTION π¦
Okay so lremove hands you back a brand new list π β the original list gets elements removed from it at every one of the indices you pass in as index arguments. And like, "zero or more" is the vibe here, you can pass as many as you want, it's an arbitrary number, no cap fr fr.
The tea on how it actually goes down:
- The indices can be in any order π and can be repeated β nobody's judging.
- If you name the same index twice, that element only gets removed once. Periodt. No double-deletion glitches. β¨
- The index values get interpreted the exact same way as index values for the
string indexcommand β so yes, you get simple index arithmetic and indices relative to the end of the list. π
And the two anchors you gotta know:
0refers to the first element of the list.endrefers to the last element of the list.
It's giving index math but make it cute. π§
π₯ EXAMPLES π₯
Removing the third element of a list β okay so 2 because we count from 0, iykyk:
% lremove {a b c d e} 2
a b d e
Removing two elements from a list β one from the end-ish, one from the front:
% lremove {a b c d e} end-1 1
a c e
Removing the same element indicated in two different ways β 2 and end-2 are literally pointing at the same lil guy, and it still only goes away once:
% lremove {a b c d e} 2 end-2
a b d e
Ate. No notes. π
π SEE ALSO π
list(3tcl), lappend(3tcl), lassign(3tcl), ledit(3tcl), lindex(3tcl), linsert(3tcl), llength(3tcl), lmap(3tcl), lpop(3tcl), lrange(3tcl), lrepeat(3tcl), lreplace(3tcl), lreverse(3tcl), lsearch(3tcl), lseq(3tcl), lset(3tcl), lsort(3tcl)
The whole list-command friend group honestly π«Ά
π KEYWORDS π
element, list, remove
That's the whole page bestie β this one's from the Tcl 9.0 era and lives under the lremove(3tcl) name. Go forth and remove things, responsibly. πβ¨π
π¦ where this page comes from
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- 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