From Tcl 8.5 [L1 ], expr operator for list inclusion test.
if {$el in $list} ...
is equivalent to, but much nicer than
if {[lsearch -exact $list $el] >= 0} ...
The negation ("not in") is ni. So 8.5 Tcl really makes us knights who say 'ni'... For users of earlier versions, the following little helper comes in handy:
proc in {list el} {expr [lsearch -exact $list $el] >= 0}} ... if [in $list $el] ...
- rs 2007-04-26
Let's see - so it would be something like:
set el Mon set list [list Mon Tue Wed Thu Fri Sat Sun] if {$el in $list} { puts "Valid day abbreviation" } else { puts "Invalid day abbreviation" }