arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1707.04724cs.LOcs.CLcs.PL
收藏

记忆法:前向、左递归和(延续传递)风格

Memoisation: Purely, Left-recursively, and with (Continuation Passing) Style

UCL(伦敦大学学院);Jukedeck Ltd.(Jukedeck有限公司)

Samer Abdallah

摘要:

Memoisation或制表是一种众所周知的技术,可以大大提高某些递归计算的性能。Prolog语言中的表分解可以将所谓的左递归谓词从非终止计算转化为有限的、行为良好的谓词。在函数式编程文献中,memoisation通常是以不处理左递归的方式实现的,需要补充机制来防止非终止性。一个值得注意的例外是Johnson(1995)在Scheme中的连续传递方法。然而,这依赖于备忘录表数据结构的变化和以显式连续传递风格的编码。我们展示了如何约翰逊的方法可以实现纯功能的现代,强类型的函数语言(OCaml),通过一个一元接口,隐藏的实现细节,但提供了一种方法来返回一个紧凑的表示的备忘录表在计算结束。

英文摘要:

Memoisation, or tabling, is a well-known technique that yields large improvements in the performance of some recursive computations. Tabled resolution in Prologs such as XSB and B-Prolog can transform so called left-recursive predicates from non-terminating computations into finite and well-behaved ones. In the functional programming literature, memoisation has usually been implemented in a way that does not handle left-recursion, requiring supplementary mechanisms to prevent non-termination. A notable exception is Johnson's (1995) continuation passing approach in Scheme. This, however, relies on mutation of a memo table data structure and coding in explicit continuation passing style. We show how Johnson's approach can be implemented purely functionally in a modern, strongly typed functional language (OCaml), presented via a monadic interface that hides the implementation details, yet providing a way to return a compact represention of the memo tables at the end of the computation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑