Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Prelude hiding (init) -- so we can use the name 'init' later
- type Automaton a = [a] -> Bool
- type AutomatonPair a = (a, Automaton a)
- accept :: Eq a => [AutomatonPair a] -> Automaton a
- accept ps = f
- where f [] = True
- f (x:xs) = case lookup x ps of
- Just a -> a xs
- Nothing -> False
- v s@('c':_) = init s
- where init = accept [('c', loop)]
- loop = accept [('a', loop),
- ('d', loop),
- ('r', end)]
- end = accept [('r', end)]
- v s = see0 s
- where see0 = accept [('0', see1)]
- see1 = accept [('1', see0)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement