Posted to tcl by bjorkintosh at Sun Feb 18 04:20:40 GMT 2024view pretty
# Define a list of words
set words {apple banana cherry date elephant}
# Define indices of elements to remove
set indicesToRemove {1 3}
# Remove elements at specified indices
set updatedWords [lmap index $indicesToRemove {
lreplace $words $index $index
}]
# Print the updated list of words
puts $updatedWords
-> {apple cherry date elephant} {apple banana cherry elephant}