函数式语言&支持记忆
当前流行的函数式语言中的任何一种都对记忆化和记忆化有良好的支持吗?如果我要根据其记忆力来选择一个,你会推荐哪一个?为什么?
更新:我正在寻找优化有向图(其中节点可以是函数或数据)。当图中的节点更新时,我希望仅当其他节点依赖于更改的节点时才重新计算其他节点的值。
Update2:需要免费或开源语言/运行时。
Do any of the current crop of popular functional languages have good support for memoization & if I was to pick one on the strength of its memoisation which would you recommend & why?
Update: I'm looking to optimise a directed graph (where nodes could be functions or data). When a node in the graph is updated I would like the values of other nodes to be recalculated only if they depend the node that changed.
Update2: require free or open-source language/runtime.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 Haskell,Conal Elliott 在 function 上发布了一篇漂亮的博客文章备忘录尝试。这项工作异常聪明且相当有深度,Conal 后来将其扩展为 多态函数。无论你使用什么语言,强烈推荐这个东西,因为它揭示了函数式语言中记忆化的深层思想。
但是,查看您的更新,并不清楚记忆是否真的是您想要的。您扩展的问题陈述(通过有向图传播更新)几乎是增量计算的教科书示例,Bob Harper 和 Umut Acar。我相信他们有一个用标准机器学习编写的免费库。查看 Umut 的页面 自我调整计算< /em>。
For Haskell, Conal Elliott has posted a beautiful blog entry on functional memo tries. The work is extraordinarily clever and quite deep, and Conal later extended it to polymorphic functions. No matter what language you use, this stuff is highly recommended, because it uncovers the deep ideas underlying memoization in functional languages.
However, looking at your update, it's not clear that memoization is really what you want. Your expanded problem statement (propagating updates through a directed graph) is an almost textbook example of incremental computation, on which a great deal of work has been done by Bob Harper and Umut Acar. I believe they have a free library written in Standard ML. Look at Umut's page on self-adjusting computation.
在 Haskell 上,请参阅此作为开始。
对于 Lisp 来说,这是来自 Google 的第一个看起来相关的点击。
对于 F# 这 可能是一个不错的起点。
现在我已经帮你谷歌搜索完了。这些支持是否有良好?你决定:-)
哦,我推荐 Mathematica,但我知道很多人都因其价格而望而却步。严格来说,它可能更像是一个术语重写系统,而不是一个函数式编程系统,而且它在任何意义上都不是纯粹的。但它确实可以记忆。
编辑:我忘记了 Erlang,它目前有很大的吸引力——我不知道如何,但我希望它可以进行记忆。
On Haskell, see this for a start.
For Lisp, this was the first hit from Google that looked relevant.
For F# this might be a good place to start.
Now I'm done Googling for you. Is any of this good support ? You decide :-)
Oh, I'd recommend Mathematica, but I understand that a lot of people are put off by its price tag. Strictly speaking it's probably more of a term-rewriting system than a functional programming system, and it's not pure in any senses of the word. But it does do memoization.
EDIT: I forgot Erlang, which has a lot of traction at the moment -- I don't know how but I expect it can do memoization.
是的,您根本不需要记忆,您需要精确的依赖性跟踪。
您可以使用 Haskell 函数图库 (fgl) 创建有向图,然后使用后继函数来准确知道要更新哪些节点:
http://hackage.haskell.org/cgi-bin/hackage- scripts/package/fgl
本文将极大地帮助人们理解文档:
http://web.engr.oregonstate.edu/~erwig/fgl/
后继函数名为 suc,位于 Data.Graph.Induction.Graph 模块中
走向不同的方向,支持此功能的一种流行函数语言是 Excel。 :)
Yeah, you don't want memoization at all, you want precise dependency tracking.
You could use the Haskell Functional Graph Library (fgl) to create ur directed graph, then use the successor function to know precisely which nodes to update:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fgl
This paper will greatly aid ind understanding the docs:
http://web.engr.oregonstate.edu/~erwig/fgl/
The successor function is named suc, in module Data.Graph.Inductive.Graph
Going in a different direction, one popular functional language that supports this is Excel. :)