Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Haskell program needs editing! Need my code edited so that it actually.matches the DFA below... will give a good rating for answers! >>DFA 0 1s0
Haskell program needs editing!
Need my code edited so that it actually.matches the DFA below... will give a good rating for answers! >>DFA 0 1s0 $1,s2,s3,s4) qs-s0 F-(s3) 8-(s0,0,$1), (s0, 1, s1), (so, . , s2), (s1,0,s1), (s1,1,s1), (s1 s3), (s2,0, s3), (s2, 1,s3), (s2, . ,s4), (s3, 0, s3), (s3, 1,s3), (s3, s4s4,0,s4), (s4,1,s4),(s4, ,s4)) where 10,1,) >> My code: type State Int type DFA (State], [Char], State->Char->State, State, [State]) dfafactory: DFA dfaFactorv (states, alphabet, delta, s, fs where states [1,2,3] alphabet- ['1 o'] delta 1 '1'-2 delta 1 '0'-2 delta 1' 2 delta 2 '1' 3 delta 2 '0' 3 delta 2-3 delta 3'1-1 delta 3 '0' 1 delta 3' 1 extendDelta.:: (State >Char->State)>(State >String >State) extendDelta delta deltaStar where deltastar q l-q deltaStar q (a:w) - deltaStar (delta q a) w dfaAccept:: DFA-> String-> Bool dfaAccept (as,alpha,delta,s,fs) w = let deltaStar - extendDelta delta q deltaStar s w in elem q fs >> sample output: Prelude> dfaAccept dfaFactor "" False . Prelude> dfaAccept dfaFactory 1" False Prelude> dfaAccept dfaactory 1.0 True Prelude> dfaccept dfaFactory 10.11" True Prelude> dfaAccept dfaFactory 10.10.10" False Need my code edited so that it actually.matches the DFA below... will give a good rating for answers! >>DFA 0 1s0 $1,s2,s3,s4) qs-s0 F-(s3) 8-(s0,0,$1), (s0, 1, s1), (so, . , s2), (s1,0,s1), (s1,1,s1), (s1 s3), (s2,0, s3), (s2, 1,s3), (s2, . ,s4), (s3, 0, s3), (s3, 1,s3), (s3, s4s4,0,s4), (s4,1,s4),(s4, ,s4)) where 10,1,) >> My code: type State Int type DFA (State], [Char], State->Char->State, State, [State]) dfafactory: DFA dfaFactorv (states, alphabet, delta, s, fs where states [1,2,3] alphabet- ['1 o'] delta 1 '1'-2 delta 1 '0'-2 delta 1' 2 delta 2 '1' 3 delta 2 '0' 3 delta 2-3 delta 3'1-1 delta 3 '0' 1 delta 3' 1 extendDelta.:: (State >Char->State)>(State >String >State) extendDelta delta deltaStar where deltastar q l-q deltaStar q (a:w) - deltaStar (delta q a) w dfaAccept:: DFA-> String-> Bool dfaAccept (as,alpha,delta,s,fs) w = let deltaStar - extendDelta delta q deltaStar s w in elem q fs >> sample output: Prelude> dfaAccept dfaFactor "" False . Prelude> dfaAccept dfaFactory 1" False Prelude> dfaAccept dfaactory 1.0 True Prelude> dfaccept dfaFactory 10.11" True Prelude> dfaAccept dfaFactory 10.10.10" FalseStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started