A good way to avoid “sharing”?

坚强是说给别人听的谎言 提交于 2019-11-30 11:07:25
Don Stewart

In this case, your pidigits list is a constant (or "constant applicative form ), and GHC will probably float it out, calculate it once, and share amongst uses. If there are no references to the CAF, it will be garbage collected.

Now, in general, if you want something to be recalculated, turn it into a function (e.g. by adding a dummy () parameter). Examples in the linked question on CAFs: How to make a CAF not a CAF in Haskell?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!