1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

Build a big vector for the memo table.

This commit is contained in:
Rob Rix 2016-06-06 23:15:33 -04:00
parent 0061d075f2
commit 3f93773159

View File

@ -82,7 +82,7 @@ memoizeEnum :: Enum a => (a -> b) -> a -> b
memoizeEnum f = (fmap f [toEnum 0 ..] !!) . fromEnum memoizeEnum f = (fmap f [toEnum 0 ..] !!) . fromEnum
memoize2d :: Int -> Int -> (Int -> Int -> a) -> (Int -> Int -> a) memoize2d :: Int -> Int -> (Int -> Int -> a) -> (Int -> Int -> a)
memoize2d width height f = outof (fmap (into f) [0..] !!) memoize2d width height f = outof (Vector.generate ((width + 1) * (height + 1)) (into f) Vector.!)
where into f i | width > 0 = if i < (width * height) where into f i | width > 0 = if i < (width * height)
then f (i `div` width) (i `mod` width) then f (i `div` width) (i `mod` width)
else f width height else f width height