You can just use lists,
let food = [
"fruit", ["blueberry"; "strawberry"; "kiwi"];
"veggie", ["broccoli"; "kale"]
]
and use List.assocto access it:
List.assoc "fruit" food
will be rated as
- : string list = ["blueberry"; "strawberry"; "kiwi"]
If you need real cards with a logarithmic search, you can use the module Map. In the standard library, it provides a functor Makethat creates a map for user-provided data, for example,
module Strings = Map.Make(String)
Strings, string - . :
let map = Strings.empty
Strings.add "fruit" ["blueberry"; "strawberry"; "kiwi"] map
, , . , , python, Hashtbl.
Hashtbl:
let food = Hashtbl.create 16
Hashtbl.add food "fruit" ["blueberry"; "strawberry"; "kiwi"]
Hashtbl.add food "veggie" ["broccoli"; "kale"]
Hashtbl.find food "veggie"
- : string list = ["broccoli"; "kale"]