aboutsummaryrefslogtreecommitdiff
path: root/motus/js/updateProposition.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2022-01-28 14:44:57 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:22:43 +0100
commit741f88ab405995003eb6e9f301d3b065c1e84a4a (patch)
tree08ba9ec2247c56680611d542ed9b096c5f1a083b /motus/js/updateProposition.ml
parentc0c82a7bfe8300b1bd50fee11074837ff32d3da0 (diff)
Added a motus solver
Diffstat (limited to 'motus/js/updateProposition.ml')
-rw-r--r--motus/js/updateProposition.ml24
1 files changed, 24 insertions, 0 deletions
diff --git a/motus/js/updateProposition.ml b/motus/js/updateProposition.ml
new file mode 100644
index 0000000..ab10db3
--- /dev/null
+++ b/motus/js/updateProposition.ml
@@ -0,0 +1,24 @@
+(** Update the current propositions when the user change a value in one of the
+ field.
+ *)
+
+open StdLabels
+
+type t =
+ { position : int
+ ; letter : Jstr.t
+ ; validity : State.letter_validity
+ }
+
+let process { position; letter; validity } state =
+ let current_prop =
+ List.mapi state.State.current_prop ~f:(fun pos' content ->
+ if position <> pos'
+ then content
+ else if Jstr.is_empty letter
+ then None
+ else Some (Jstr.uppercased letter, validity) )
+ in
+ FieldList.set_with_props current_prop state.fields state.rules;
+
+ { state with current_prop }