def next_except.go
import unified-nsga-iii@0.2.2.0/rng.bend as Rngimport Base
95# C# NextExcept: uniform in [0, n) distinct from exclude when n > 1.
96def next_except.go(s: State, +exclude: Nat, n: Nat) -> State:
97 match n:
98 case 0n:
99 with_k(s, 0n)
100 case 1n:
101 with_k(s, 0n)
102 case 1n+m:
103 +s2 = next_nat(s, m)
104 +v = last_nat(s2)
105 with_k(s2, bump_except(v, exclude, Nat.is_lt(v, exclude)))