Skip to content

Instantly share code, notes, and snippets.

@laMudri
Last active March 18, 2020 22:57
Show Gist options
  • Save laMudri/e8c53f43f87b348b453e3d55fbc2bc3e to your computer and use it in GitHub Desktop.
Save laMudri/e8c53f43f87b348b453e3d55fbc2bc3e to your computer and use it in GitHub Desktop.
data Bracket = Open | Close
data Nat = Ze | Su Nat
isZero :: Nat -> Bool
isZero Ze = True
isZero (Su _) = False
match :: [Bracket] -> Bool
match = go Ze
where
go :: Nat -> [Bracket] -> Bool
go l [] = isZero l
go l (Open : w) = go (Su l) w
go Ze (Close : w) = False
go (Su l) (Close : w) = go l w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment