aboutsummaryrefslogtreecommitdiff
path: root/motus/js
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/js
parentd20d14b4f4a903ef9aea4c01dd46fab5ecbab6ae (diff)
Hide structure in motus solver
Diffstat (limited to 'motus/js')
-rw-r--r--motus/js/motus.ml5
-rw-r--r--motus/js/next.ml2
-rw-r--r--motus/js/reload.ml16
3 files changed, 14 insertions, 9 deletions
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 ->