Searching a list
As with any data contained within a program, it is the ability to locate and use that data that makes the program usable. To accomplish this, Tcl provides not only a command, but also a full complement of option flags to tailor the search. The lsearch
command allows us to search a list to determine if it contains a particular element. Before we explore the syntax, we will first need to understand the options. The options are as follows:
Type of option |
Option name |
Interpretation |
---|---|---|
Matching style options |
|
The pattern is a literal string that is compared against each element. |
|
The pattern is a glob-style pattern that is matched against each element in the same manner, as a string match. | |
|
The pattern is treated as a regular expression and matched against each element. | |
|
The list elements are sorted in order. If specified, |