aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Utils.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Utils.hs b/lib/Utils.hs
index 1381f16..61c4e49 100644
--- a/lib/Utils.hs
+++ b/lib/Utils.hs
@@ -43,3 +43,9 @@ sublists = concatMap inits . tails
43 43
44windows :: Int -> [a] -> [[a]] 44windows :: Int -> [a] -> [[a]]
45windows m = foldr (zipWith (:)) (repeat []) . take m . tails 45windows m = foldr (zipWith (:)) (repeat []) . take m . tails
46
47kadane :: [Int] -> Int
48kadane = go 0 0
49 where go :: Int -> Int -> [Int] -> Int
50 go best _ [] = best
51 go best current (l:ls) = go (max best (current + l)) (max current (current + l)) ls