This commit is contained in:
Ingy döt Net 2013-06-05 21:47:54 +00:00
parent 1f1ad49427
commit 6f050a029e
2496 changed files with 37609 additions and 3031 deletions

View file

@ -1,7 +1,6 @@
maxsubseq = mss_ (0,[]) (0,[]) where
mss_ _ x [] = x
mss_ here sofar (x:xs) = mss a b xs where
a = max (0,[]) (fst here + x, snd here ++ [x])
maxsubseq = snd . foldl f ((0,[]),(0,[])) where
f ((h1,h2),sofar) x = (a,b) where
a = max (0,[]) (h1 + x, h2 ++ [x])
b = max sofar a
main = print $ maxsubseq [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1]