def AP.swap_t
bend-osdev-array@0.1.0.1 · PROOF.bend:545
import bend-osdev-array@0.1.0.1/PROOF.bend as PROOF
import Base
545def AP.swap_t(-T: Data, t: AP.Tree<T>, n: U32, +i: U32, v: T, z: Bool) -> AP.Tree<T>:
546 match t z:
547 case APLeaf{x} _:
548 APLeaf{v}
549 case APNode{xs, ys} True{}:
550 +h = U32.shr(n)
551 APNode{AP.swap_t(T, xs, h, i, v, U32.is_lt(i, U32.shr(h))), ys}
552 case APNode{xs, ys} False{}:
553 +h = U32.shr(n)
554 +j = U32.sub(i, h)
555 APNode{xs, AP.swap_t(T, ys, h, j, v, U32.is_lt(j, U32.shr(h)))}