def suggest

cli@0.2.0.0 · cli.bend:5755

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

5755# At most 3 names within max(1, n / 3) edits, by distance, then order.
5756# key is bound because a temporary argument makes String.length take its
5757# string, adding a keep to each caller that reuses one (Nat.read.fits,
5758# arg_display).
5759def suggest(+typed: String, names: List<&2, String>) -> List<&2, String>:
5760  key = undashed(typed)
5761  +limit = Nat.max(1n, Nat.div(String.length(key), 3n))
5762  List.take(&2, String, by_distance((limit + 1n : Nat), 0n,
5763    scored(names, String.take(typed, 64n), limit)), 3n)

Uses (12)

Used by (1)