def jpeg.history.valid
gralha-jpeg-decode@0.1.0.1 · jpeg.bend:535
import gralha-jpeg-decode@0.1.0.1/jpeg.bend as Jpeg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-bytes@0.1.0.1/bytes.bend as Bin
535
536
537def jpeg.history.valid(n: Nat, +index: U32, +history: Bin.Bytes, +high: U32) -> Bool:
538 match n:
539 case 0n: True{}
540 case 1n+d: U32.is_eq(Bin.bytes.get(history, index), U.choose(U32, U32.is_eq(high, 0), 0, U32.inc(high))) && jpeg.history.valid(d, U32.inc(index), history, high)