Last active
June 15, 2017 15:25
-
-
Save deque-blog/84380918206dc37994696e71b8534cd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
score' : Nat -> Vect n Frame -> List Nat -> Nat | |
score' current [] _ = current | |
score' current (f :: fs) rolls = | |
let frameRollNb = length (knockedPins f) -- Nb of rolls in the frame | |
scoreRollNb = frameRollNb + bonusRolls f -- Nb of rolls to sum | |
frameScore = sum (take scoreRollNb rolls) -- Sum of the rolls to sum | |
in score' -- Recur: | |
(current + frameScore) -- Add the frame score to the current score | |
fs -- Advance the the next frame | |
(drop frameRollNb rolls) -- Advance to the next rolls | |
score : BowlingGame -> Nat | |
score game@(MkBowlingGame frames bonus) = score' 0 frames (gameRolls game) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment