Skip to content

Instantly share code, notes, and snippets.

@pta2002
Created December 1, 2022 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pta2002/dfe130522335cf395857fba1e1cbca8e to your computer and use it in GitHub Desktop.
Save pta2002/dfe130522335cf395857fba1e1cbca8e to your computer and use it in GitHub Desktop.
parseList :: GenParser Char st CalorieList
parseList = sepBy (try group) (string "\n\n")
group :: GenParser Char st [Int]
group = sepBy integer (char '\n')
integer :: GenParser Char st Int
integer = read <$> many1 digit
countCalories :: CalorieList -> [Int]
countCalories = map sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment