Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awalterschulze/ca6659f9babc8f9d656fe26d5ec764a2 to your computer and use it in GitHub Desktop.
Save awalterschulze/ca6659f9babc8f9d656fe26d5ec764a2 to your computer and use it in GitHub Desktop.
medium-derivative-of-a-regex-derive-answer-3.hs
derive "a*(b|c)" 'b'
= (derive "a*" 'b') `concat` "b|c"
`or`
(derive "b|c" 'b')
= (derive "a" 'b') `concat` "a*" `concat` "b|c"
`or`
(derive "b" 'b') `or` (derive "c" 'b')
= "∅" `concat` "a*" `concat` "b|c"
`or`
"ε" `or` "∅"
= "(∅a*(b|c))|(ε|∅)"
= "ε"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment