blob: e2e531d986fb3fc70e8f8451f4f0ee130f633219 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
open StdLabels
open Motus_lib
type proposition = (Jstr.t * Validity.t) option list
type state =
{ analysis : Wordlist.t
; catalog : Wordlist.t
; rules : Criteria.t list
; length : int
; propositions : proposition list
; current_prop : proposition
; fields : Brr.El.t list
}
let init () =
{ analysis = Wordlist.empty_data ()
; catalog = Wordlist.empty_data ()
; rules = []
; length = 0
; propositions = []
; current_prop = []
; fields = []
}
module App = Application.Make (struct
type t = state
end)
(** Get the current rules to apply with from the field list *)
let get_current_rules : proposition -> Criteria.t list =
fun prop ->
let rules = ref [] in
List.iteri prop ~f:(fun i prop ->
Option.iter
(fun (letter, validity) ->
if Jstr.equal Jstr.empty letter
then ()
else
let char = String.get (Jstr.to_string letter) 0 in
rules := Validity.to_criteria char i validity !rules )
prop );
List.rev !rules
(** Compare two states *)
let eq : state -> state -> bool =
fun s1 s2 ->
(s1.length, s1.rules, s1.current_prop, s1.propositions, s1.analysis)
= (s2.length, s2.rules, s2.current_prop, s2.propositions, s2.analysis)
|