Posted to tcl by bjorkintosh at Sun Feb 18 04:20:40 GMT 2024view raw

  1. # Define a list of words
  2. set words {apple banana cherry date elephant}
  3.  
  4. # Define indices of elements to remove
  5. set indicesToRemove {1 3}
  6.  
  7. # Remove elements at specified indices
  8. set updatedWords [lmap index $indicesToRemove {
  9. lreplace $words $index $index
  10. }]
  11.  
  12. # Print the updated list of words
  13. puts $updatedWords
  14.  
  15. -> {apple cherry date elephant} {apple banana cherry elephant}