For the complete documentation index, see llms.txt. This page is also available as Markdown.

BoxSetFind

Return the first element of a Set for which the predicate returns true, or null if no element matches.

Iteration follows the natural order of the underlying variant and stops at the first match. The predicate receives the element value, its 1-based ordinal position, and the Set itself.

Method Signature

BoxSetFind(set=[set], callback=[function:Predicate])

Arguments

Argument
Type
Required
Description
Default

set

set

true

The set to search.

callback

function:Predicate

true

Predicate invoked for each element. Receives {@code (value, ordinal, set)}. Iteration stops at the first element for which this returns {@code true}.

Examples

Find the first element that satisfies a predicate

Returns the matching element, or null when nothing matches.

s = [ 1, 2, 3, 4, 5 ].toSet();
found = s.find( ( Any v ) => v > 3 );
writeOutput( found >= 4 ? "yes" : "no" );

Result: yes

Returns null when no element matches

Result: null

Last updated

Was this helpful?