Skip to content

@lang:all

Whether every element satisfies the predicate.

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

Returns: bool

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

Check every element of the array return of a call against a predicate, on-chain: a foldWords with the All exit (init 1), stopping at the first failure.

The predicate is a def @name! of one parameter returning bool, applied by name. Its parameter substitutes wherever the body names it. def @ge100! "$x: number -> bool" @bool!($x >= 100) tests element >= 100; a body of @bool!(not $x) tests element == 0. A predicate reducing to ONE Operators call becomes a single-staticcall template; a composed one — a nested live call, a multi-call body like @bool!($x > $vault::floor()) — routes through the core, which resolves the expression per element at several staticcalls each. Both compile; the one-call form is the cheap one.

load lang
set $vault 0x44fA8E6f47987339850636F88629646662444217
# Every cap at least 100
def @ge100! "$x: number -> bool" @bool!($x >= 100)
assert @all!($vault::{caps()(uint256[])} @ge100!)
# No flag set
def @isOff! "$x: bool -> bool" @bool!(not $x)
assert @all!($vault::{flags()(bool[])} @isOff!)
  • Arrays of single-word elements only.
  • An empty array is vacuously true (the fold returns its init).
  • assert, @any!, @reduce!