Skip to content

Instantly share code, notes, and snippets.

@mgechev
Created July 5, 2013 11:00
Show Gist options
  • Select an option

  • Save mgechev/5933790 to your computer and use it in GitHub Desktop.

Select an option

Save mgechev/5933790 to your computer and use it in GitHub Desktop.
The sum of all sub lists of given list which don't have negative values in them
sumProd :: [[Integer]]->Integer
sumProd lst = sum (map product (filter (\x -> length ([y | y <- x, y < 0]) == 0) lst))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment