如何使用 GHood 或 Vacuum 观察此递归函数?
我正在使用 GHood 来观察分区函数的执行情况,并期望看到一棵二叉树。相反,我得到了这棵树:
import Debug.Observe
p :: (Observable a, Ord a, Num a) => a -> a -> a
p k n
| k > n = 0
| k == n = 1
| otherwise = (observe "left" p (k+1) n ) + (observe "right" p k (n-k))
>>> printO $ observe "p" p 1 3
我也尝试使用 Data.Number.Natural
根据 irc 上的建议。
当使用 Vacuum.Cairo 时,我得到的返回值甚至更少,只有函数运行完成的结果。
>>> m: + System.Vacuum.Cairo
>>> view $ p 1 5
I'm using GHood to watch the execution of this implementation of the partition function and expected to see a binary tree. Instead I get this tree:
import Debug.Observe
p :: (Observable a, Ord a, Num a) => a -> a -> a
p k n
| k > n = 0
| k == n = 1
| otherwise = (observe "left" p (k+1) n ) + (observe "right" p k (n-k))
>>> printO $ observe "p" p 1 3
I've also unsuccessfully tried using lazy natural numbers from Data.Number.Natural
as per a suggestion on irc.
When using Vacuum.Cairo
I get even less back, just the result of the function run to completion.
>>> m: + System.Vacuum.Cairo
>>> view $ p 1 5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论