def cut
import ezx@1.11.0.0/src/ws/workspace.bend as Workspaceimport Base
42# the segments before the last, when the last is the word: `libs/*` cut at
43# `*` is `libs`, and `cli/ez.toml` cut at `ez.toml` is `cli`. A path whose last
44# segment is another word cuts to nothing.
45def cut(ss: List<&2, String>, +word: String) -> Maybe<&2, List<&2, String>>:
46 match ss:
47 case []:
48 None{}
49 case +hd <> []:
50 cut.last(String.eq(hd, word))
51 case +hd <> tl:
52 cut.cons(hd, cut(tl, word))