English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Polymorphic comparison
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1994-10-18 (12:48)
From: Franck.Delaplace@l...
Subject: Polymorphic comparison

>I think this polymorphic comparison is quite easy to implement in the
>following way:

>#open "hashtbl";;
>let c x y = (hash x) <= (hash y);;
>

this kind of comparison would not be  appropriate in some cases.
for example when you want to use it for sorting strings 

    c "ace" "af";;

gives

- : bool = false


by convention, we intend to have this relation "ace" <= "af" since the comparison is defined
by comparing the substrings "ac" "af"