def glob_chars

near-v-framework@0.4.0.0 · domain/architecture/system/deployment/azure/ops.bend:62

import near-v-framework@0.4.0.0/domain/architecture/system/deployment/azure/ops.bend as Ops
import Base

62# ---- permissions ----
63# ARM patterns use '*' for zero or more characters; matching is case insensitive.
64def glob_chars(+ps: List<&2, Char>, +vs: List<&2, Char>) -> Bool:
65  match ps:
66    case []:
67      match vs:
68        case []:
69          True{}
70        case _ <> _:
71          False{}
72    case p <> rest:
73      match p:
74        case '*':
75          match vs:
76            case []:
77              glob_chars(rest, [])
78            case v <> tail:
79              glob_chars(rest, v <> tail) || glob_chars('*' <> rest, tail)
80        case _:
81          match vs:
82            case []:
83              False{}
84            case v <> tail:
85              Char.is_eq(p, v) && glob_chars(rest, tail)

Uses (9)

Used by (1)