FIND

Synopsis
FIND conditiontemplate data
Description

Outputs the first item of the data input for which the value produced by evaluating conditiontemplate with that item in its slot is TRUE. If there is no such item, then FIND outputs the empty list.

In a template, the symbol ?REST represents the portion of the data input to the right of the member currently being used as the ? slot-filler. For example, if the data input is [A B C D E] and the template is being evaluated with ? replaced by B, then ?REST would be replaced by [C D E].

In a template, the symbol # represents the position in the data input of the member currently being used as the ? slot-filler. For example, if the data input is [A B C D E] and the template is being evaluated with ? replaced by B, then # would be replaced by 2.

Example
TO NEGATIVEP :number
  OUTPUT :number < 0
END

SHOW FIND "NEGATIVEP [2 4 3 0]
[]
SHOW FIND "NEGATIVEP [2 1 0 -3 -6]
-3

SourceForge.net Logo