~ubuntu-branches/ubuntu/karmic/ocaml-doc/karmic

« back to all changes in this revision

Viewing changes to examples/compress/fileprio.ml

  • Committer: Bazaar Package Importer
  • Author(s): Vanicat Rémi
  • Date: 2002-02-05 10:51:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020205105143-a061tunf8tev07ne
Tags: 3.04-4
* New debian maintainer
* Split doc-base file
* Move to non-free
* Change the copyright file to the copyright of the documentation
* remove FAQs (their license prohibit their redistribution)
* corrected the examples

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
exception File_vide;;
 
2
 
 
3
type 'a t =
 
4
   | Vide | File of int * 'a * 'a t * 'a t;;
 
5
 
 
6
let vide = Vide;;
 
7
 
 
8
let rec enl�ve_sommet = function
 
9
  | Vide -> raise File_vide
 
10
  | File(prio, elt, Vide, Vide) -> Vide
 
11
  | File(prio, elt, gauche, Vide) -> gauche
 
12
  | File(prio, elt, Vide, droite) -> droite
 
13
  | File(prio, elt, (File(prio_g, elt_g, _, _) as gauche),
 
14
                    (File(prio_d, elt_d, _, _) as droite)) ->
 
15
      if prio_g < prio_d
 
16
      then File(prio_g, elt_g, enl�ve_sommet gauche, droite)
 
17
      else File(prio_d, elt_d, gauche, enl�ve_sommet droite);;
 
18
 
 
19
let extraire = function
 
20
  | Vide -> raise File_vide
 
21
  | File(prio, elt, _, _) as file -> (prio, elt, enl�ve_sommet file);;
 
22
 
 
23
let rec ajoute file prio elt =
 
24
  match file with
 
25
  | Vide ->
 
26
      File(prio, elt, Vide, Vide)
 
27
  | File(prio1, elt1, gauche, droite) ->
 
28
      if prio <= prio1
 
29
      then File(prio, elt, ajoute droite prio1 elt1, gauche)
 
30
      else File(prio1, elt1, ajoute droite prio elt, gauche);;