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
[Caml-list] sorting Hashtbl.t
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-08-14 (23:25)
From: Alexander V.Voinov <avv@q...>
Subject: Re: [Caml-list] sorting Hashtbl.t

From: John Max Skaller <skaller@ozemail.com.au>
Subject: Re: [Caml-list] sorting Hashtbl.t
Date: Thu, 15 Aug 2002 08:16:47 +1000

> > 
> > 	From an algorithmic point of view, there is no way to sort an
> > hash table since there is no order attached to items. 
> Ocaml has a polymorphic comparison function (which works
> on all non-cyclic data structures). Therefore, any collection
> of (non-cyclic) data elements can be sorted, and the request
> actually makes sense. It is also something I wish to do
> often.
> However, I would ask for different function(s):
> 	Hastbl.to_list
> 	Hashtbl.to_lista
> 	Hashtbl.to_sorted_list compar
> 	Hashtbl.to_sorted_lista compar

I second this.

I've already defined something similar in a recent application, actually
equivalents of Python's .keys(), .values() and .items() with a subsequent sort
but I'd be happy with this interface as well.

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners