Cold Help System: Programming: ColdC Reference Manual: Language Structure: Expressions: Looping Expressions: find


The find expression is used to find the position of something in a list or dictionary. It does this by looping through the given list or dictionary and testing the iteration expression. When the iteration expression evaluates true it stops and returns the given position. The syntax of find is:

find var in (what expr) where (iteration expr)
find var in [lower expr .. upper expr] where (iteration expr)

If iteration expression never evaluated true, find returns a zero. The following examples assume the variable list is set as:

["First line","second line","3rd line"]
list[find x in (list) where (x.match_regexp("co"))]
=> "second line"
find x in [1 .. listlen(list)] where (list[x].match_regexp("co"))
=> 2


map | hash | find | filter


the Cold Dark