def gat.go
import bend-parallel@0.1.0.0/sort.bend as Sortimport Base
434# r holds perm and its entry x at j: dst[j] <- src[x], then the n entries
435# after j.
436def gat.go(~T: Data, +n: Nat, +j: U32, p: Sd<T>, r: Array<U32> & U32) -> Moved<T>:
437 match n:
438 case 0n:
439 (pm, +x) = r
440 gat.fin(~T, pm, gat.one(~T, j, x, p))
441 case 1n+q:
442 (pm, +x) = r
443 +i = (j + 1 : U32)
444 gat.go(~T, q, i, gat.one(~T, j, x, p), pm[i])