Created
August 31, 2022 09:02
-
-
Save awalterschulze/ce715c85161ee9d149553a9cf2411860 to your computer and use it in GitHub Desktop.
medium-derivative-of-a-regex-derive-answer-2.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
derive "b*(b|c)" 'b' | |
= (derive "b*" 'b') `concat` "b|c" | |
`or` | |
(derive "b|c" 'b') | |
= (derive "b" 'b') `concat` "b*" `concat` "b|c" | |
`or` | |
(derive "b" 'b') `or` (derive "c" 'b') | |
= "ε" `concat` "b*" `concat` "b|c" | |
`or` | |
"ε" `or` "∅" | |
= "(εb*(b|c))|(ε|∅)" | |
= "b*(b|c)|ε" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment