我正在尝试在Haskell中构建一个数据结构,其中的函数可以用来避免重新计算值。例如,假设我有这个功能:
f :: Int -> Int -> Int
f 1 1 == 1
f m n
| abs m > n = 0
| OTHERWISE if value of f m n has already been computed by another recursive branch, return that value and add it to the "database"
| OTHERWISE return f (m-1) (n-1) + f (m - 1) n
我已经查看过memoization,但是无法实现解决方案:\
连连呢? :)