caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Fonction polymorphe
@ 1996-01-24 18:47 Hubert Canon
  1996-02-01 14:03 ` Pierre Weis
  1996-02-01 14:03 ` Eric Hassold
  0 siblings, 2 replies; 3+ messages in thread
From: Hubert Canon @ 1996-01-24 18:47 UTC (permalink / raw)
  To: caml-list


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/
------------------------------------------------------------------





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-02-01 15:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-01-24 18:47 Fonction polymorphe Hubert Canon
1996-02-01 14:03 ` Pierre Weis
1996-02-01 14:03 ` Eric Hassold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).