@lang:find
First element that satisfies the predicate; no match is an error.
On-chain (@lang:find!): The predicate is a named def @name! of one parameter returning bool, applied by name.
Returns: any
Syntax
Section titled “Syntax”@lang:find(arr fn)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
arr | array | Source array |
fn | helper | Predicate helper returning bool |
See Also
Section titled “See Also”On-chain face (@find!)
Section titled “On-chain face (@find!)”The first matching element of the array return of a call: a
filterWords with the predicate (the same lambda machinery @filter!
uses) and a core pick of the kept payload's first word.
Examples
Section titled “Examples”load lang
set $vault 0x44fA8E6f47987339850636F88629646662444217
# The first cap at or above the floor is exactly the floordef @ge100! "$x: number -> bool" @bool!($x >= 100)assert @find!($vault::{caps()(uint256[])} @ge100!) == 100- NO MATCH REVERTS the assertion at judge time: the pick lands past an empty kept payload. The off-chain @find raises its "no element matched" error at run time instead — there is no undefined result on either face.
- The element carries the array's element category (an address array yields an address-comparable word).
See Also
Section titled “See Also”assert,@filter!,@includes!,@any!