aboutsummaryrefslogtreecommitdiff
path: root/motus/bin
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2022-02-11 09:22:18 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-11 09:28:26 +0100
commit82bb54622a47bb092094c8efab8200b12817c5b4 (patch)
treef160d66a09d2bf0e8f2bdbef5dbec17126ecd4a1 /motus/bin
parentd20d14b4f4a903ef9aea4c01dd46fab5ecbab6ae (diff)
Hide structure in motus solver
Diffstat (limited to 'motus/bin')
-rw-r--r--motus/bin/motus.ml14
1 files changed, 5 insertions, 9 deletions
diff --git a/motus/bin/motus.ml b/motus/bin/motus.ml
index fe00a3c..0f2b17b 100644
--- a/motus/bin/motus.ml
+++ b/motus/bin/motus.ml
@@ -24,7 +24,7 @@ let show_structure :
(Format.pp_print_list format_filter)
filters;
- Format.fprintf format "Got %d elements @\n" data.number;
+ Format.fprintf format "Got %d elements @\n" (Persistence.list_size data);
Format.fprintf
format
@@ -32,14 +32,14 @@ let show_structure :
(Format.pp_print_list (fun f (k, v) -> Format.fprintf f "%c -> %d" k v))
(Persistence.extract_freq data);
- if data.number < 20
+ if Persistence.list_size data < 20
then
Format.fprintf
format
"Remaining words @[<v>@;%a@]@\n"
(Format.pp_print_list ~pp_sep:Format.pp_force_newline (fun f w ->
Format.fprintf f "%s" w ) )
- data.element;
+ (Persistence.words data);
Format.close_box ()
@@ -97,11 +97,7 @@ let rec run filters words =
(* if the input is empty, remove the word from the list and restart *)
match String.equal String.empty input with
- | true ->
- let new_words =
- List.filter (fun w -> not (String.equal w next)) words.element
- in
- run filters { words with element = new_words; number = words.number - 1 }
+ | true -> run filters (Persistence.remove_word words next)
| false ->
let new_rules =
Criteria.merge_lists ~init:filters (create_new_rules next input)
@@ -112,7 +108,7 @@ let rec run filters words =
List.fold_left
(Persistence.add_word new_rules)
(Persistence.empty_data ())
- words.element
+ (Persistence.words words)
in
run new_rules words