Add a numeric checker

F# |> I❤️
This commit is contained in:
joachimschmidt557 2019-02-06 22:24:32 +01:00
parent 7652c5b86d
commit 20201692a1
9 changed files with 32 additions and 3 deletions

27
IsNumericChecker.fs Normal file
View file

@ -0,0 +1,27 @@
module Tests
open System
open DFA
let numericDFA:DFA = {
sigma = Seq.toList "01ab";
states = [
{name = "yes"};
{name = "no"}
];
delta = (fun x y ->
match (x, y) with
| ({name = "yes"}, '0') -> {name = "yes"}
| ({name = "yes"}, '1') -> {name = "yes"}
| _ -> {name = "no"}
);
beginState = {name = "yes"};
acceptingStates = [{name = "yes"}]
}
let test =
printfn "Testing numeric checker DFA"
printfn "Is valid DFA: %b" (DFA.validateDFA numericDFA)
printfn "0101: %b" (DFA.acceptsWord numericDFA "0101")
printfn "01a1: %b" (DFA.acceptsWord numericDFA "01a1")
0