[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 1996-02-01 (13:38) |
From: | Hubert Canon <canon@p...> |
Subject: | Fonction polymorphe |
Un bug probable de caml-light : j'ai une fonction qui devrait etre polymorphe, mais elle change de type au premier appel : Avec caml light 7beta2 (le code n'est pas de moi) : #let permutations = let rec permut fixe = fun [] [] -> [fixe] | debut [] -> [] | debut (x :: suite) -> (permut (fixe @ [x]) [] (debut @ suite)) @ (permut fixe (debut @ [x]) suite) in permut [] [];; - : permutations : '_a list -> '_a list list = <fun> #permutations ["3";"456";""];; - : string list list = [["3"; "456"; ""]; ["3"; ""; "456"]; ["456"; "3"; ""]; ["456"; ""; "3"]; [""; "3"; "456"]; [""; "456"; "3"]] #permutations;; - : string list -> string list list = <fun> #permutations [1;2];; Entrée interactive: >permutations [1;2];;<EOF> > ^^^^^^^^^^ Cette expression est de type int list, mais est utilisée avec le type string list. -- -------------------------- Hubert Canon -------------------------- Email : canon@poly.polytechnique.fr WWW : http://www.polytechnique.fr/poly/~canon/ ------------------------------------------------------------------