def pmax

bendtorch@1.3.0.0 · main.bend:1325

import bendtorch@1.3.0.0/main.bend as Bendtorch
import Base

1325# the largest of a[idx] (held in r) and the k numbers after it: max(max(a0, a1), a2) ..., from the first
1326def pmax(k: Nat, +idx: U32, cur: F32, r: Array<F32> & F32) -> AS:
1327  match k r:
1328    case 0n Tuple{a, +x}:
1329      AS{a, F32.max(cur, x)}
1330    case 1n+q Tuple{a, +x}:
1331      pmax(q, (idx + 1 : U32), F32.max(cur, x), Array.get(F32, a, (idx + 1 : U32)))

Uses (10)

Used by (1)