def key_once_at

bend-schema-lib@0.4.1.0 · core.bend:451

import bend-schema-lib@0.4.1.0/core.bend as Core
import Base

451# name appears at most once among the keys of the object r. b is whether a key
452# read before r was already name; the flag carries forward, and a key that is
453# name while the flag is set is the second one -- refused here and nowhere
454# else. The value is the first argument because a self-call must read its
455# arguments left to right, unchanged until one shrinks, and only the value
456# shrinks; the value is matched first because a match cannot be nested inside
457# the branch of a match on another parameter. One pass, so a walk costs one
458# key per key, the same as the lookup beside it.
459def key_once_at(r: Raw, +b: Bool, +name: String) -> Bool:
460  match r:
461    case RKey{+k, +v, +o}:
462      Bool.and(Bool.not(Bool.and(b, String.eq(k, name))), key_once_at(o, Bool.or(b, String.eq(k, name)), name))
463    case _:
464      True{}

Uses (7)

Used by (1)