def swap_perm

bendtorch@1.3.0.0 · tensor.bend:518

import bendtorch@1.3.0.0/tensor.bend as Tensor
import Base

518# 0..n-1 with i and j swapped
519def swap_perm(n: Nat, +i: Nat, +a: Nat, +b: Nat) -> List<&2, Nat>:
520  match n:
521    case 0n:
522      Nil{}
523    case 1n+r:
524      Bool.pick(Nat, Nat.is_eq(i, a), b, Bool.pick(Nat, Nat.is_eq(i, b), a, i)) <> swap_perm(r, 1n+i, a, b)

Uses (4)

Used by (1)