Add complement of DFA
This commit is contained in:
parent
2708e66b19
commit
94699949eb
1 changed files with 11 additions and 1 deletions
10
DFA.fs
10
DFA.fs
|
|
@ -70,3 +70,13 @@ let rec processCharArray (dfa: DFA) (state: String) (charArr: Char list) =
|
|||
let acceptsWord (dfa: DFA) (word: String) =
|
||||
dfa.acceptingStates
|
||||
|> List.contains (processCharArray dfa dfa.beginState (Seq.toList word))
|
||||
|
||||
let complement (dfa: DFA) : DFA =
|
||||
{
|
||||
sigma = dfa.sigma;
|
||||
states = dfa.states;
|
||||
delta = dfa.delta;
|
||||
beginState = dfa.beginState;
|
||||
acceptingStates = dfa.states
|
||||
|> List.filter (fun x -> not (List.contains x dfa.acceptingStates))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue