Guest User

Untitled

a guest
Jul 27th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 1.27 KB | None | 0 0
  1.      
  2. let conversionDijonctive sDepart =
  3.     let rec aux var s mot res = match s with
  4.         ""->res
  5.         |a->begin
  6.             match (Strin.sub a 0 1) with
  7.                 '+'-> if (appartenance mot var) (* Si mot Contient toutes les vars/leurs négations *) then
  8.                         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 *)
  9.                     else
  10.                         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*)
  11.                 |'!'-> 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
  12.                 |_-> 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
  13.             end
  14.     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