Guest User

Untitled

a guest
Jul 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. (* Interface est_dans
  2. Type : ('a * 'a list) -> bool
  3. Arguments : e, l
  4. Précondition : Aucune
  5. Postcondition: Dit si e est dans l
  6. Raises : Aucune
  7. Tests :
  8.  
  9. est_dans (10,[]);; (*false*)
  10. est_dans (10,[10;19]);; (*true*)
  11. est_dans (10,[19;10]);; (*true*)
  12.  
  13. *)
  14.  
  15. let rec est_dans (e,l) = match l with
  16. | [] -> false
  17. | a::q -> if a=e then true else est_dans (e,q);;
  18.  
  19. est_dans (10,[]);;
  20. est_dans (10,[10;19]);;
  21. est_dans (10,[19;10]);;
  22.  
  23.  
  24. (* Interface compare
  25. Type : ('a list * 'a list) -> bool
  26. Arguments : a, b
  27. Précondition : Aucune
  28. Postcondition : dit si les éléments de a sont tous dans b
  29. Raises : Aucune
  30. Tests :
  31.  
  32. compare ([],[10;19]);; (*true*)
  33. compare ([10],[10;19]);; (*true*)
  34. compate ([10;18;19],[10;19]);; (*false*)
  35.  
  36. *)
  37.  
  38. let rec compare (a,b) = match a with
  39. | [] -> true #par convention, mais ne genera pas par la suite
  40. | e1::q -> if est_dans(e1,b) then compare (q,b) else false;;
  41.  
  42. compare ([],[10;19]);;
  43. compare ([10],[10;19]);;
  44. compare ([10;18;19],[10;19]);;
  45.  
  46. (* Interface pas_deux_fois
  47. Type : ('a * 'a list) -> 'a list
  48. Arguments : a, l
  49. Précondition : Aucune
  50. Postcondition : Retire les doublons dans une liste
  51. Raises : Aucune
  52. Tests :
  53.  
  54. *)
  55.  
  56. Let rec pas_deux_fois (a,l) = match l with
  57. | [] -> []
  58. | _::a::q -> if est_dans (a,q) then _::q else _::a::q;;
  59.  
  60.  
  61. (* Interface etapeaux
  62. Type : (string list * (int, string, string list) list * string list) -> string list A VERIFIER !!!!!!!!!!!
  63. Arguments : rgs, fts, acc
  64. Précondition : Aucune
  65. Postcondition : fonction qui réalise étape lorsque acc = []
  66. Raises : Aucune
  67. Tests
  68.  
  69. *)
  70.  
  71. let rec etapeaux (rgs, fts, acc) = match (rgs,fts) with
  72. | (_,[]) -> []
  73. | ((_,P,a)::r,b) -> if compare (a,b) then etapeaux (r, fts, P::acc) else etapeaux (r, fts, acc);;
  74.  
  75.  
  76. (* Interface etape
  77. Type : (string list * (int, string, string list) list) -> string list
  78. Arguments : rgs, fts, acc
  79. Précondition : Aucune
  80. Postcondition : A COMPLETER
  81. Raises : Aucune
  82. Tests :
  83.  
  84. *)
  85.  
  86. let etape (rgs, fts) = etapeaux (rgs, fts, []);;
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. (* Définition des négations *)
  96.  
  97. type prop = Var of string | Non of string;;
Add Comment
Please, Sign In to add comment