Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let conversionDijonctive sDepart =
- let rec aux var s mot res = match s with
- ""->res
- |a->begin
- match (Strin.sub a 0 1) with
- '+'-> if (appartenance mot var) (* Si mot Contient toutes les vars/leurs négations *) then
- aux var ( String.sub s ((String.length mot)+1) ((String.length s)-((String.length mot)+1)) )(* <=>reste de s *) ""(* on démarre un nouveau mot=>nouvelle String *) (mot::res)(* on ajoute le mot à res *)
- else
- aux var ( String.sub s ((String.length mot)+1) ((String.length s)-((String.length mot)+1)) )(* <=>reste de s *) ""(* on démarre un nouveau mot=>nouvelle String *) ((completion mot var)@res)(* FORMULE MAGIQUE QUI COMPLETE LE MOT*)
- |'!'-> aux var ( String.sub s (2) ((String.length s)-(String.length mot)) )(* <=>reste de s *) (mot^(String.sub a 0 1)^(String.sub a 1 1))(* on continue de construire le mot en prenant deux lettres car on tombe sur une négation *) res
- |_-> aux var ( String.sub s (1) ((String.length s)-(String.length mot))-1 )(* <=>reste de s *) (mot^(String.sub a 0 1))(* on continue de construire le mot *) res
- end
- in aux (lecture sDepart) (sDepart^"+") "" [] ;; (* sDepart^"+" pour gérer le cas abcd+a sinon a ne sera pas compléter*)
Add Comment
Please, Sign In to add comment