Index Mathematics Conjectures nbv lettuce Widgets

if_ne!

Run a block if two static values differ. Control flow

if_ne! lhs, rhs { ... }

The complement of if_eq!: compares two values known at compile time and runs the block once, in a fresh inner scope, if they are not equal. Vectors of different lengths count as different.

Arguments

lhs, rhs
Static values or witness constants, scalars or vectors.
{ ... }
Required block. It may not end in a final expression; it can assign mut variables of the enclosing scopes.

Returns

Nothing, it is used as a statement.

Constraints

None of its own. Behaves the same in the static VM.

Example

(let x)
static mode = 1
let mut out = x[0]
if_eq! mode, 0 {
  out = x[0] + x[1]
}
if_ne! mode, 0 {
  out = x[0] + x[1] + x[2]
}
out

Used in the standard library

is_zero, lattice/lattice_digest, polynomial/bit_reverse_indices, r1cs/r1cs_compose_vertical, r1cs/r1cs_into_output, typed/typed_lattice_digest_bits