I\'m trying to memoize the following function:
gridwalk x y | x == 0 = 1 | y == 0 = 1 | otherwise = (gridwalk (x - 1) y) + (gridwalk x (y - 1)) <
Here is a version using Data.MemoTrie from the MemoTrie package to memoize the function:
Data.MemoTrie
import Data.MemoTrie(memo2) gridwalk :: Int -> Int -> Int gridwalk = memo2 gw where gw 0 _ = 1 gw _ 0 = 1 gw x y = gridwalk (x - 1) y + gridwalk x (y - 1)