(* donnees *) let noms = ["Lendormi";"Malencontreux";"Louravi";"Tricaillou"; "Maladroit";"Lebougnat";"Letordu";"Ledroit";"Letourdi";"Connor"; "Legnidu";"Lapache";"Panhard";"Dutronc";"Alcazar" ];; let prenoms = ["Nestor";"Jules";"Arsene";"Cesar";"Leandre";"Egmont"; "Clovis";"Marius";"Clothaire"; "Samantha";"Aglae";"Barbara";"Fanny";"Josephine";"Agatha";"Emily"; "Sharon";"Chloe";"Ernestine";"Georgina";"Sarah" ];; let rec n_ieme n = function | [] -> failwith "pas assez d'objets" | t::_ when n=0 -> t | _::q -> n_ieme (n-1) q ;; let choisit_dans l = n_ieme (random__int (list_length l)) l ;; let cree_liste n noms prenoms = let rec aux accu = function | 0 -> accu | n -> let prenom = choisit_dans prenoms and nom = choisit_dans noms in let s = concat [prenom;" ";nom] in if mem s accu then aux accu n else aux (s::accu) (n-1) in aux [] n ;; (* outils de generation de l'etat des depenses *) let min_dep = 100 and max_dep = 200 and effectif = 30 ;; let entier_alea p q = p + random__int q ;; let cree_ligne nom = let montant = entier_alea min_dep max_dep in concat [nom;"*"; string_of_int montant;"\n"] ;; let enregistre_etat etat nom_fich = let fd = open_out nom_fich in do_list (output_string fd) etat; close_out fd ;; let cree_etat n = let l = cree_liste n noms prenoms in map cree_ligne l ;; enregistre_etat (cree_etat effectif) "totor" ;;