list contains and tip 133 
Author Message
 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



Tue, 27 Sep 2005 03:06:07 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. TIP #133: Extending [expr] Operators

2. Reading more than 133 bytes

3. Program lockup on AST 133

4. Canon Pentium 133, 16 MB, Complete System

5. 486 dx4/100 faster than p-133?

6. Printing to PC 133 characters

7. INFO-ADA Digest V93 #133

8. Which gui for slow (133 Mhz) pc

9. Parsing a CSV file containing quoted strings (themselves containing commas)

10. Refering to substring of list containing strings

11. list containing same character

 

 
Powered by phpBB® Forum Software