How to implement a dictionary as a function in OCaml?
I am learning Jason Hickey's Introduction to Objective Caml . Here is an exercise I don't have any clue First of all, what does it mean to implement a dictionary as a function ? How can I image that? Do we need any array or something like that? Apparently, we can't have array in this exercise, because array hasn't been introduced yet in Chapter 3 . But How do I do it without some storage? So I don't know how to do it, I wish some hints and guides. I think the point of this exercise is to get you to use closures. For example, consider the following pair of OCaml functions in a file fun-dict.ml