3

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: enter image description here

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
4

0 回答 0