Module Tabulate.ForOrderedType

ForOrderedType is a special case of Make where it suffices to pass a finite ordered type as an argument. A reference to a persistent map is used to hold the table.


module F : sig ... end
module T : sig ... end


type key = F.t

The type of keys.

val tabulate : (key -> 'a) -> key -> 'a

tabulate is a tabulation combinator for the type key. The function call tabulate f produces a function f' that behaves extensionally like f, but is tabulated.

Like memoization, tabulation guarantees that, for every key x, the image f x is computed at most once. Unlike memoization, where this computation takes place on demand, here, the computation of f x for every x takes place eagerly, when tabulate is invoked. The graph of the function f, a table, is constructed and held in memory.