RosettaCodeData/Task/Associative-array-Creation/OCaml/associative-array-creation-4.ocaml

13 lines
266 B
Text
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
module String = struct
type t = string
let compare = Pervasives.compare
end
module StringMap = Map.Make(String);;
let map =
List.fold_left
(fun map (key, value) -> StringMap.add key value map)
StringMap.empty
["foo", 5; "bar", 10; "baz", 15]
;;