Index Mathematics Conjectures nbv lettuce Widgets

shadow_loop!

Run a block a static number of times in the enclosing scope. Loops and mapping

shadow_loop! count[, i] { ... }

Like loop!, but the block runs directly in the enclosing scope instead of a fresh inner scope. Variables defined in the block, and the counter, stay defined after the loop, each iteration shadowing the definitions of the previous one.

Arguments

count
Static scalar (or a witness constant), the number of iterations.
i
Optional. A bare variable name bound to the static iteration index, still defined after the loop with the last index.
{ ... }
Required block. It may not end in a final expression.

Returns

Nothing, it is used as a statement.

Constraints

None of its own; the block's operations add theirs once per iteration. Behaves the same in the static VM.

Example

(let x)
shadow_loop! 3, i {
  let last = x[i] * x[i]
}
last

Notes

Used in the standard library

ext/ext_eq_table, ext/mle_eq_table, slip/slip_r1cs_arg_verify