* [Caml-list] Data structure for efficient maps ?
@ 2004-06-30 12:09 Diego Olivier Fernandez Pons
0 siblings, 0 replies; only message in thread
From: Diego Olivier Fernandez Pons @ 2004-06-30 12:09 UTC (permalink / raw)
To: caml-list
Bonjour,
Does anyone know about a persistent (purely functional) data structure
designed to handle efficiently inner maps for integers ?
The only way I know to do this is to rebuild completely the data
structure by something like
map f data = from_list (List.map f (to_list data))
which isn't very efficient when handling large data sets
example of use
let sigma = function
| 0 -> 1
| 1 -> 2
| 2 -> 6
| 3 -> 3
| 4 -> 0
| 5 -> 4
| 6 -> 5
| _ -> failwith "invalid argument"
let myset = Set.from_list [0;4;5;6]
let newset = Set.map sigma myset (* should be efficent here *)
# Set.to_list newset
- [0;1;4;5]
Diego Olivier
-------------------
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-06-30 12:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-30 12:09 [Caml-list] Data structure for efficient maps ? Diego Olivier Fernandez Pons
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox