Does this Haskell function memoize?
问题 I'd like to pre-calculate some values that are then used when I need to do further lookups. I came up with the following: import qualified Data.Vector.Unboxed as V lcgen s = lc where lc 0 b = lengths V.! b lc a b = lengths V.! b - lengths V.! (a - 1) - 1 lengths = V.fromList $ scanl1 ((+) . (1 +)) $ map length $ words s The function essentially returns the number of characters used in-between two words. I use it as follows: let lc = lcgen "some sentence with a lot of words" lc 0 0 -- == 4 lc