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
Re: [Caml-list] Sorting
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-11-02 (15:06)
From: Krishnaswami, Neel <neelk@c...>
Subject: Re: [Caml-list] Sorting
Marcin 'Qrczak' Kowalczyk [mailto:qrczak@knm.org.pl] wrote:
> What are advantages and disadvantages in parametrizing either by '<'
> or by the 3-way comparison?

If comparisons are very expensive -- for instance, if the elements
are long strings or large sets -- then it makes for faster execution
to use a three-way comparison. On the average you will do two-thirds
as many comparisons while sorting with a three-way comparison. 

I find this irritating becuase it just *feels* nicer to pass a 
function of type elt -> elt -> bool to a sorting function. It's
closer to how sorting is taught, and hence to my mental model. :)

Neel Krishnaswami
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr