Change from State struct to just strings

This commit is contained in:
joachimschmidt557 2019-02-20 19:31:18 +01:00
parent fa48bc49d1
commit 30949252c0
4 changed files with 36 additions and 40 deletions

14
DFA.fs
View file

@ -2,8 +2,6 @@ module DFA
open System
type State = { name: String }
///
/// A deterministic finite automaton
///
@ -11,14 +9,14 @@ type DFA = {
/// All possible characters
sigma: Char list
/// All possible states
states: State list
states: String list
/// All possible transitions
delta: State -> Char -> State
delta: String -> Char -> String
/// The state this DFA begins in
beginState: State
beginState: String
/// The states in which this DFA accepts
/// the word
acceptingStates: State list
acceptingStates: String list
}
/// Returns true if the DFA is valid, false otherwise
@ -51,12 +49,12 @@ let validateDFA (dfa:DFA) =
/// Returns the state the DFA is in after
/// reading this character
let processChar (dfa: DFA) (state: State) (char: Char) =
let processChar (dfa: DFA) (state: String) (char: Char) =
dfa.delta state char
/// Returns the state the DFA is in after
/// reading this character array
let rec processCharArray (dfa: DFA) (state: State) (charArr: Char list) =
let rec processCharArray (dfa: DFA) (state: String) (charArr: Char list) =
match charArr with
| [] -> state
| head :: tail -> processCharArray dfa (processChar dfa state head) tail