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. That is, 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]. If multiple parallel slots are used, then (?REST 1) goes with ?1, etc.

In a template, the symbol # represents the position in the data input of the member currently being used as the ? slot-filler. That is, 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 MYFIND :arg
  IF :arg=1 [OUTPUT "true]
  OUTPUT "false
END

SHOW (FIND "MYFIND [2 4 3 0])
[]
SHOW (FIND "MYFIND [2 1 3 0])
1

SourceForge.net Logo