From 82bb54622a47bb092094c8efab8200b12817c5b4 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 11 Feb 2022 09:22:18 +0100 Subject: Hide structure in motus solver --- motus/js/motus.ml | 5 ++++- motus/js/next.ml | 2 +- motus/js/reload.ml | 16 +++++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'motus/js') diff --git a/motus/js/motus.ml b/motus/js/motus.ml index f2995df..a2bcbd3 100644 --- a/motus/js/motus.ml +++ b/motus/js/motus.ml @@ -172,7 +172,10 @@ let main let last_element = S.map (fun ev -> - match (ev.State.current_prop, ev.State.analysis.number) with + match + ( ev.State.current_prop + , Motus_lib.Persistence.list_size ev.State.analysis ) + with | [], _ | _, 1 -> Some (Jstr.v "true") | _, _ -> None ) ev diff --git a/motus/js/next.ml b/motus/js/next.ml index 658590d..5f24883 100644 --- a/motus/js/next.ml +++ b/motus/js/next.ml @@ -19,7 +19,7 @@ let process : t -> State.state -> State.state = List.fold_left ~f:(Motus_lib.Persistence.add_word rules) ~init:(Motus_lib.Persistence.empty_data ()) - state.analysis.Motus_lib.Persistence.element + (Motus_lib.Persistence.words state.analysis) in let propositions = state.current_prop :: state.propositions diff --git a/motus/js/reload.ml b/motus/js/reload.ml index 3a461ee..cfdfa2a 100644 --- a/motus/js/reload.ml +++ b/motus/js/reload.ml @@ -1,3 +1,5 @@ +(** Reload the list without the current proposition *) + open StdLabels type t = unit @@ -15,15 +17,15 @@ let process : t -> State.state -> State.state = |> String.of_seq in - let element = - List.filter - ~f:(fun w -> not (String.equal w word)) - state.State.analysis.element + let new_state = + { state with + analysis = Motus_lib.Persistence.remove_word state.analysis word + } in - let analysis = { state.analysis with element } in - let new_state = { state with analysis } in (* Get the new proposition if any *) - let current_prop = Initialize.get_proposition analysis state.rules in + let current_prop = + Initialize.get_proposition new_state.analysis state.rules + in match current_prop with | None -> new_state | Some prop -> -- cgit v1.2.3