Version 0 of lremove

Updated 2006-03-26 23:04:34

How to remove items from a list not by their position (lreplace) but by the actual content. My solution would be:

 proc K { x y } { set x }
 proc lremove { listvar string } {
         upvar $listvar in
         foreach item [K $in [set in [list]]] {
                 if {[string equal $item $string]} { continue }
                 lappend in $item
         }
 }

which gives us

 % set a [list a b c a b c a b c]
 a b c a b c a b c
 % lremove a b
 % set a
 a c a c a c

Is there any reason not to do it that way?

Gotisch