Is there a way to update a list from within a foreach loop that is working on the list? Here's an example ...
set nos [list 1 2 3 4 5 6]
% foreach one $nos {
if {$one == 4} {
lappend nos 7
}
if {$one == 7} {puts "List dynamically updated"}
}
This code does update the list but doesn't produce the output. Any offers?
set nos [list 1 2 3 4 5 6]
% foreach one $nos {
if {$one == 4} {
lappend nos 7
}
if {$one == 7} {puts "List dynamically updated"}
}
This code does update the list but doesn't produce the output. Any offers?