Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Data structure for efficient maps ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@e...>
Subject: [Caml-list] Data structure for efficient maps ?
    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