Skip to content

Instantly share code, notes, and snippets.

@piotrplaneta
Created October 9, 2013 11:58
Show Gist options
  • Select an option

  • Save piotrplaneta/6900115 to your computer and use it in GitHub Desktop.

Select an option

Save piotrplaneta/6900115 to your computer and use it in GitHub Desktop.
go max lastMax [] = max
go max lastMax (x : xs)
| lastMax + x < 0 = go max 0 xs
| lastMax + x > max = go (lastMax + x) (lastMax + x) xs
| otherwise = go max (lastMax + x) xs
maxsum = go 0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment