list contains and tip 133
In TIP 133
http://www.*-*-*.com/
it is mentioned:
[...]
Inclusion of a value in a list is frequently tested with the construct
if {[lsearch -exact $list $value] >= 0} {...}
The proposal, first brought by Reinhard Max in the Tcl Chatroom, is to
allow an in operator in the language understood by [expr], and the
condition parts of [for], [if] and [while], so that the above can be
written as
if {$value in $list} {...}
This is shorter to type and much better to read.
[...]
What about just extending the lsearch command to understand
lsearch -contains $list $value
and return 0 or 1 accordingly?
Cheers
Daniel