Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 50 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. type mois_t = Janvier|Fevrier|Mars|Avril|Mai|Juin|Juillet|Aout|Septembre|Octobre|Novembre|Decembre;;
  2. type date_t = {jour:int; mois:mois_t; annee:int};;
  3. let correct_date d = let correct_mois d =
  4.     match d.mois with
  5.     | Avril| Juin| Septembre| Novembre -> d.jour <= 30
  6.     | Fevrier when d.annee mod 4 = 0 -> d.jour <= 29
  7.     | Fevrier -> d.jour <= 28
  8.     | _ -> d.jour <= 31
  9.     in d.annee >= 1900 && d.annee <= 2008 && d.jour >= 1 && correct_mois d;;
  10.    
  11. type enregistrement = {nom:string; prenom:string; date:date_t}
  12.    
  13. let rec ajout_pers bdd pers =
  14.     match bdd with
  15.     | [] -> [pers]
  16.     | a::r -> if (a.nom > pers.nom || a.nom = pers.nom && a.prenom = pers.prenom) then pers::a::r else a::ajout_pers r pers;;
  17.  
  18. let rec suppr_pers bdd pers =
  19.     match bdd with
  20.     | [] -> []
  21.     | a::r -> if (a.nom = pers.nom && a.prenom = pers.prenom && a.date = pers.date) then suppr_pers r pers else a::suppr_pers r pers;;
  22.  
  23. let rec search_pers bdd nom =
  24.     match bdd with
  25.     | [] -> failwith "Cette personne n'existe pas"
  26.     | a::r -> if (a.nom = nom) then a else search_pers r nom;;
  27.  
  28.    
  29. (* General *)
  30. let rec nais_at bdd jour mois =
  31.     match bdd with
  32.     |[] -> []
  33.     | a::r -> if (a.date.jour = jour && a.date.mois = mois) then a::nais_at r jour mois else nais_at r jour mois;;
  34.  
  35. (* Correction *)   
  36. let rec douze_mars bdd =
  37.     match bdd with
  38.     | [] -> []
  39.     | a::r when a.date.jour = 12 && a.date.mois = Mars -> a::douze_mars r
  40.     | a::r -> douze_mars r;;
  41.  
  42. (* General *)
  43. let rec start_by bdd letter =
  44.     match bdd with
  45.     | [] -> []
  46.     | a::r -> if (Char.uppercase (String.get a.nom 0) = Char.uppercase letter) then a::start_by r letter else start_by r letter;;
  47.  
  48. (* Correction *)
  49. let rec nomD bdd =
  50.     match bdd with
  51.     | [] -> []
  52.     | a::r when a.nom < "D" -> nomD r
  53.     | a::r when a.nom < "E" -> a::(nomD r)
  54.     | a::r -> [];;
  55.    
  56. let req select query bdd =
  57.     match bdd with
  58.     | [] -> []
  59.     | a::r when (query a) -> a::select query r
  60.     | a::r -> select query r;;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top