def key_rank

cli@0.2.0.0 · cli.bend:2634

import cli@0.2.0.0/cli.bend as Cli
import Base

2634# The position of the first of keys named query, where hit says whether
2635# keys' head is and at is its position. It only reads keys: a walk that
2636# takes them, as find_key does, copies every field of each key it passes.
2637def key_rank(keys: List<&2, OptKey>, +query: String, at: Nat, hit: Bool) ->
2638    Maybe<&2, Nat>:
2639  match keys hit:
2640    case Nil{} _: None{}
2641    case key <> tail True{}: Some{at}
2642    case key <> +tail False{}:
2643      next = head_named(tail, query)
2644      key_rank(tail, query, 1n+at, next)

Uses (7)

Used by (2)