Disposable memo functions (extended abstract)
暂无分享,去创建一个
A memoized function, or memo function, remembers the arguments to which it has been applied, together with the resulting computation. If it is applied to the same argument again it returns the stored answer rather than repeating the computation. Memorization haa been proposed as a solution to numerous problems because it improves the asymptotic complexity of algorithms with redundant computations. However, most schemes for memorization can consume vast amounts of memory that are only garbage-collectible by heuristic means. In contrast, we give a semantics for memorization aa an extension to the lazy J-calculus computational model. Programmers will find that managing the space consumption of memoized functions is comparable to managing the space requirements of any other value in the heap. This is an important contribution because previous purging approaches required that programmers adopt new and foreign reasoning pnncipak. The key idea of this paper is to adapt the Hughes’s [2] research on lazy memo-functions and supply a function memo with type:
[1] Paul Hudak,et al. Functional reactive animation , 1997, ICFP '97.
[2] John Hughes,et al. Lazy Memo-functions , 1985, FPCA.
[3] E. Meijer,et al. Monadic parser combinators , 1996 .