Files
tricu/lib/patterns.tri
James Eversole fdebb6c13d Tricu 2.0.0
Sorry for squashing all of this but 🤷
2026-05-25 12:44:24 -05:00

41 lines
734 B
Plaintext

!import "prelude" !Local
match_ = y (self value patterns :
triage
t
(_ : t)
(pattern rest :
triage
t
(_ : t)
(test result :
if (test value)
(result value)
(self value rest))
pattern)
patterns)
match = (value patterns :
match_ value (map (sublist :
pair (head sublist) (head (tail sublist)))
patterns))
otherwise = const (t t)
cond_ self patterns =
lazyList
(_ : t)
(pattern rest :
matchPair
(testK actionK :
lazyBool
actionK
(_ : self rest)
(testK t))
pattern)
patterns
cond patterns = y cond_ patterns
guard testK actionK = pair testK actionK