[Haskell-cafe] List algorithm
Mark T.B. Carroll
mark at ixod.org
Mon May 21 19:53:07 EDT 2007
mark at ixod.org (Mark T.B. Carroll) writes:
(snip)
> algMemo n m = lookupMemo m
> where
> memo = [[]] : map helper [1..m]
> lookupMemo m = if m < 0 then [] else memo !! m
> helper m' = [ x : xs | x <- [1..n], xs <- lookupMemo (m' - x) ]
which, I suppose, is rather like,
algMemo n m = last memo
where
memo = [[]] : map helper [1 .. m]
helper m' = [ x : xs | x <- [1 .. min m' n], xs <- memo !! (m' - x) ]
-- Mark
More information about the Haskell-Cafe
mailing list