let rec score_bowls bowls =
let rec score_bowls' frame l =
let sum b = (List.fold_right (fun x y -> x + y) b 0)
let nextframe = score_bowls' (frame+1)
match l with
| _ when frame = 10 -> sum l
| [10;s] -> 10 + s + s
| 10 :: s :: n :: tail -> 10 + s + n + nextframe (s :: n :: tail )
| f :: s :: n :: tail -> f + s + (if((f+s)=10) then n else 0) + nextframe (n :: tail)
| _ -> sum l
score_bowls' 1 bowls
No comments:
Post a Comment