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
NFA.fs
View file

@ -2,31 +2,29 @@ module NFA
open System
type State = { name: String }
/// A non-deterministic finite automaton
type NFA = {
/// All possible characters
sigma: Char list
/// All possible states
states: State list
states: String list
/// All possible transitions
delta: State -> Char -> State list
delta: String -> Char -> String list
/// The state this NFA begins in
beginState: State
beginState: String
/// The states in which this NFA accepts
/// the word
acceptingStates: State list
acceptingStates: String list
}
/// Returns a list of possible states after this charater
/// was read
let processChar (nfa: NFA) (state: State) (char: Char) =
let processChar (nfa: NFA) state (char: Char) =
nfa.delta state char
/// Returns a list of possible states after this character
/// list was read
let rec processCharArray (nfa: NFA) (states: State list) (charArr: Char list) : State list =
let rec processCharArray (nfa: NFA) (states: String list) (charArr: Char list) : String list =
match charArr with
| [] -> states
| head :: tail ->