abr.ml 502 B

123456789101112131415161718192021222324252627282930313233343536
  1. type 'a arbre = Vide | Noeud of 'a * 'a arbre * 'a arbre;;
  2. let rec max_arbre arbre1 = match arbre1 with
  3. | Vide -> 0
  4. | Noeud(r,g,d)-> max (max r (max_arbre g)) (max_arbre d)
  5. ;;
  6. type 'a infini = Infplus| Infmoins | Valeur of 'a ;;
  7. (* let inferieurstrict x y = match scrutinee with
  8. | pattern -> pattern *)
  9. type abr = Vide | Noeud of int * abr * abr;;
  10. let rec test_abr a = match a with
  11. | Vide -> true
  12. | Noeud(r,g,d)-> ((r>=max_arbre g)&&(r<min_arbre)&&(test_abr g)&&(test_abr d))
  13. ;;