Name

search — Find the first instance of something in a list.

Synopsis

search list varname script

Description

The search command is similar to filter in functionality, except that it stops searching on the first match.

Example

set lst {1 2 3 4 5 4 3 2 1}
puts [search $lst x {= $x 4}]
	  

Produces:

4