def first

cswap-bend-cli@0.1.0.0 · policy/pick.bend:211

import cswap-bend-cli@0.1.0.0/policy/pick.bend as Pick
import Base
import cswap-bend-cli@0.1.0.0/policy/types.bend as T
import cswap-bend-cli@0.1.0.0/policy/usage.bend as U
import cswap-bend-cli@0.1.0.0/policy/rank.bend as R

211# The first account (sequence order breaks ties) whose candidate headroom is h.
212def first(+as: List<&2, T.Account>, +s: R.Sel, +h: Nat) -> Maybe<&2, Nat>:
213  match as:
214    case Nil{}:
215      None{}
216    case Con{a, t}:
217      first.pick(first.hit(R.cand(a, s), h), U.account.slot(a), first(t, s, h))

Uses (9)

Used by (1)