Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type aut = {alpha: string array; final: bool array; trans: int array array};;
- let a = {alpha=[|"*";"a";"b"|]; final = [|false;true;false|]; trans= [| [|2;0;1|];[|0;2;1|];[|2;2;2|] |] }; ;;
- exception String_is_Empty of string;;
- let match_state tester aut current_state =
- (* find the acceptance for tester by matching it with the current transmissions array and the right index for tester and then checking if the resulting state is one of the accepted. *)
- match tester with
- |[] -> []
- |"a" -> final.(aut.trans.(current_state).(1))
- |"b" -> final.(aut.trans.(current_state).(2))
- let rec accepts_from aut s state =
- match s with
- |[] -> 0
- |[hd] -> match_state hd aut state
- |hd :: tl -> match_state hd aut state && accepts_from aut tl state
- let accepts aut s =
- if String.length s <> 0 then accepts_from aut s 0 else raise (String_is_Empty "Eingabestring")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement