Skip to content

Instantly share code, notes, and snippets.

@songpp
Created January 18, 2011 10:09
Show Gist options
  • Save songpp/784251 to your computer and use it in GitHub Desktop.
Save songpp/784251 to your computer and use it in GitHub Desktop.
maxSum' :: [Int] -> Int -> Int -> Int
maxSum' [] maxEnd maxSofar = maxSofar
maxSum' (x:xs) maxEnd maxSofar =
maxSum' xs maxEnd' (max maxSofar maxEnd')
where maxEnd' = max (maxEnd + x) 0
maxSum :: [Int] -> Int
maxSum arr = maxSum' arr 0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment