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 index command β€” so yes, you get simple index arithmetic and indices relative to the end of the list. πŸ‘‘

And the two anchors you gotta know:

  • 0 refers to the first element of the list.
  • end refers 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