Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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";;


- : bool = false

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