Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Interface est_dans
- Type : ('a * 'a list) -> bool
- Arguments : e, l
- Précondition : Aucune
- Postcondition: Dit si e est dans l
- Raises : Aucune
- Tests :
- est_dans (10,[]);; (*false*)
- est_dans (10,[10;19]);; (*true*)
- est_dans (10,[19;10]);; (*true*)
- *)
- let rec est_dans (e,l) = match l with
- | [] -> false
- | a::q -> if a=e then true else est_dans (e,q);;
- est_dans (10,[]);;
- est_dans (10,[10;19]);;
- est_dans (10,[19;10]);;
- (* Interface compare
- Type : ('a list * 'a list) -> bool
- Arguments : a, b
- Précondition : Aucune
- Postcondition : dit si les éléments de a sont tous dans b
- Raises : Aucune
- Tests :
- compare ([],[10;19]);; (*true*)
- compare ([10],[10;19]);; (*true*)
- compate ([10;18;19],[10;19]);; (*false*)
- *)
- let rec compare (a,b) = match a with
- | [] -> true #par convention, mais ne genera pas par la suite
- | e1::q -> if est_dans(e1,b) then compare (q,b) else false;;
- compare ([],[10;19]);;
- compare ([10],[10;19]);;
- compare ([10;18;19],[10;19]);;
- (* Interface pas_deux_fois
- Type : ('a * 'a list) -> 'a list
- Arguments : a, l
- Précondition : Aucune
- Postcondition : Retire les doublons dans une liste
- Raises : Aucune
- Tests :
- *)
- Let rec pas_deux_fois (a,l) = match l with
- | [] -> []
- | _::a::q -> if est_dans (a,q) then _::q else _::a::q;;
- (* Interface etapeaux
- Type : (string list * (int, string, string list) list * string list) -> string list A VERIFIER !!!!!!!!!!!
- Arguments : rgs, fts, acc
- Précondition : Aucune
- Postcondition : fonction qui réalise étape lorsque acc = []
- Raises : Aucune
- Tests
- *)
- let rec etapeaux (rgs, fts, acc) = match (rgs,fts) with
- | (_,[]) -> []
- | ((_,P,a)::r,b) -> if compare (a,b) then etapeaux (r, fts, P::acc) else etapeaux (r, fts, acc);;
- (* Interface etape
- Type : (string list * (int, string, string list) list) -> string list
- Arguments : rgs, fts, acc
- Précondition : Aucune
- Postcondition : A COMPLETER
- Raises : Aucune
- Tests :
- *)
- let etape (rgs, fts) = etapeaux (rgs, fts, []);;
- (* Définition des négations *)
- type prop = Var of string | Non of string;;
Add Comment
Please, Sign In to add comment