diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2022-01-28 14:44:57 +0100 | 
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:22:43 +0100 | 
| commit | 741f88ab405995003eb6e9f301d3b065c1e84a4a (patch) | |
| tree | 08ba9ec2247c56680611d542ed9b096c5f1a083b /motus/js/reload.ml | |
| parent | c0c82a7bfe8300b1bd50fee11074837ff32d3da0 (diff) | |
Added a motus solver
Diffstat (limited to 'motus/js/reload.ml')
| -rw-r--r-- | motus/js/reload.ml | 31 | 
1 files changed, 31 insertions, 0 deletions
diff --git a/motus/js/reload.ml b/motus/js/reload.ml new file mode 100644 index 0000000..3a461ee --- /dev/null +++ b/motus/js/reload.ml @@ -0,0 +1,31 @@ +open StdLabels + +type t = unit + +let process : t -> State.state -> State.state = + fun () state -> +  (* Get the word corresponding to the proposition *) +  let word = +    state.State.current_prop +    |> List.to_seq +    |> Seq.map (fun opt -> +           match opt with +           | None -> ' ' +           | Some (letter, _) -> String.get (Jstr.to_string letter) 0 ) +    |> String.of_seq +  in + +  let element = +    List.filter +      ~f:(fun w -> not (String.equal w word)) +      state.State.analysis.element +  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 +  match current_prop with +  | None -> new_state +  | Some prop -> +      FieldList.set_with_props prop state.fields new_state.rules; +      State.{ new_state with current_prop = prop }  | 
