def word_rest

cli@0.2.0.0 · cli.bend:4792

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

4792# Some{None{}} when text is the word name, Some{Some{rest}} when it is name,
4793# a space and rest, None{} otherwise. Words are cut at spaces, so a name with
4794# a space (Chr{32}) is no word.
4795def word_rest(name: String, text: String, same: Bool) ->
4796    Maybe<&2, Maybe<&2, String>>:
4797  match name text same:
4798    case _ _ False{}: None{}
4799    case SNil{} SNil{} True{}: Some{None{}}
4800    case SNil{} SCon{Chr{32}, rest} True{}: Some{Some{rest}}
4801    case SCon{Chr{32}, xs} _ True{}: None{}
4802    case SCon{x, xs} SCon{y, ys} True{}: word_rest(xs, ys, Char.is_eq(x, y))
4803    case _ _ _: None{}

Uses (8)

Used by (1)