Skip to content

@lang:any

Whether at least one element satisfies the predicate.

On-chain (@lang:any!): The predicate is a named def @name! of one parameter returning bool, applied by name.

Returns: bool

@lang:any(arr fn)
NameTypeDescription
arrarraySource array
fnhelperPredicate helper returning bool
  • @all — true if all match
  • @filter — keep matching elements

Check whether at least one element of the array return of a call passes a predicate, on-chain: a foldWords with the Any exit (init 0), stopping at the first pass.

The predicate is a def @name! of one parameter returning bool, applied by name: def @isZero! "$x: number -> bool" @bool!($x == 0) tests element == 0. A body reducing to ONE Operators call becomes a single-staticcall template; a composed one — a nested live call, a multi-call expression — routes through the core and costs several staticcalls per element instead of one.

load lang
set $vault 0x44fA8E6f47987339850636F88629646662444217
# Some cap is unset
def @isZero! "$x: number -> bool" @bool!($x == 0)
assert @any!($vault::{caps()(uint256[])} @isZero!) == false
  • Arrays of single-word elements only.
  • An empty array is false (the fold returns its init).
  • assert, @all!, @includes!