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


The filter expression is used to selectively pull elements from a list or dictionary. It loops through the given list or dictionary and adds each element to a new list if the iteration expression tests true. The final list is returned after filter finishes looping. The syntax of filter is:

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

The following examples assume the variable list is set as:

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


map | hash | find | filter


the Cold Dark