Created
April 18, 2013 07:12
-
-
Save Rembane/5410787 to your computer and use it in GitHub Desktop.
Just some scribblings. Carry on. :)
This file contains hidden or 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
| import qualified Data.Set as S | |
| type State = String | |
| type Letter = String | |
| type Alphabet = S.Set Letter | |
| {- | |
| data Automaton = Automaton { auto_state :: S.Set State | |
| , auto_alphabet :: Alphabet | |
| , auto_delta :: (State -> Letter -> State) | |
| , auto_start :: State | |
| , auto_final :: S.Set State | |
| } | |
| -} | |
| data Automaton = Automaton (S.Set State) Alphabet (State -> Letter -> State) State (S.Set State) | |
| delta1 :: State -> Letter -> State | |
| delta1 "q0" "0" = "q1" | |
| delta1 "q0" "1" = "q0" | |
| delta1 "q1" "0" = "q0" | |
| delta1 "q1" "1" = "q1" | |
| a1 = (Automaton (S.fromList ["q0", "q1"]) (S.fromList ["0", "1"]) delta1 (S.fromList ["q0"])) | |
| -- Applies the product between to Automatons and returns a new one. | |
| product' :: Automaton -> Automaton -> Automaton | |
| product' (Automaton states1 alphabet1 delta1 start1 final1) (Automaton states2 alphabet2 delta2 start2 final2) = (Automaton states1 alphabet1 delta1 start1 final1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment