aztec-nr - noir_aztec::protocol::utils::for_loop

Function for_i_in_

pub fn for_i_in_<Env1, Env2, Env3>(
    min: u32,
    max: u32,
    MIN: u32,
    MAX: u32,
    f_before_min: fn[Env1](u32),
    f_within: fn[Env2](u32),
    f_after_max: fn[Env3](u32),
    assert_min_lte_max: bool,
    assert_max_lte_MAX: bool,
)

Iterates between loop bounds and conditionally executes functions according to the below explanation, where:

  • min and max are dynamic loop bounds (known only at runtime).
  • MIN and MAX are static loop bounds (known at compile time).

MIN ------

       f_before_min is executed for MIN <= i < min   

<=
min ------

       f_within is executed for min <= i < max    

<= max ------

       f_after_max is executed for max <= i < MAX  

<= MAX ------

Lambda functions of the form |i| { my_array[i].assert_empty() } (for example) can be specified.