Précédent Index Suivant



Le typage de CAML VII



Polymorphisme
Lors du typage, certaines variables de type restent indéterminées. Le programme est très général !

#let app_tab f t =
   for i = 0 to vect_length t - 1 do
     t.(i) <- f (t.(i))
   done;;
app_tab : ('a -> 'a) -> 'a vect -> unit = 
<fun>
#let ajout n t = 
   app_tab (function x -> x+n) t;;
ajout : int -> int vect -> unit = <fun>
#let not_tab t = 
   app_tab (function x -> not x) t;;
not_tab : bool vect -> unit = <fun>

Intérêt du polymorphisme

Précédent Index Suivant