Tcl Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.
Ticket UUID: 684433
Title: lsearch multiple pattern matching
Type: RFE Version: None
Submitter: nobody Created on: 2003-02-11 07:51:51
Subsystem: 17. Commands I-L Assigned To: dkf
Priority: 5 Medium Severity:
Status: Open Last Modified: 2003-02-11 07:51:51
Resolution: None Closed By:
    Closed on:
The glob command can accept many pattern arguments 
but the lsearch do not. As it is often interesting to 
search lists for several elements, this feature could be 

lsearch ?switches? list pattern ?pattern...?

This syntax is totally compatible with the current lsearch 
command. It would provide a smart replacement for:

set newList {}
foreach pattern patternList {
   set result [lsearch ?switches? $list $pattern]
   set newList [concat $newList $pattern]

It would then be possible to easily find the common 
elements of 2 lists:

eval lsearch -all -inline [list $list1] $list2

or to delete list elements that are already in the second 

eval lsearch -all -not -inline [list $list1] $list2

JM. Philippe