The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Message from discussion Test Driven Development Sample

From:
To:
Cc:
Followup To:
Subject:
 Validation: For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon.

More options Dec 4 2003, 2:57 am
Newsgroups: comp.object
From: ig...@yahoo.com (Isaac Gouy)
Date: 3 Dec 2003 23:57:33 -0800
Local: Thurs, Dec 4 2003 2:57 am
Subject: Re: Test Driven Development Sample

ig...@yahoo.com (Isaac Gouy) wrote in message <news:ce7ef1c8.0311241350.3d6a6b0e@posting.google.com>...

We can use a similar approach to accumlate the intermediate bowling
scores for a possibly incomplete sequence of valid throws - update the
sequence after each throw and recalculate the scores.

Start = scores [10, 4,6, 10, 4,6, 10, 4,6, 10, 4,6] [] 0 0

scores pins a total 10    = a
scores []   a total count = a
scores [x]  a total count = a

scores [x,y] a total count
| x == 10   = a
| x+y == 10 = a
| otherwise = a++[total+x+y]

scores [x,y,z:rest] a total count
| x == 10   = scores [y,z:rest] (a++[total+x+y+z]) (total+x+y+z)
(count+1)
| x+y == 10 = scores   [z:rest] (a++[total+x+y+z]) (total+x+y+z)
(count+1)
| otherwise = scores   [z:rest] (a++[total+x+y])   (total+x+y)
(count+1)

The answer in this case would be [20,40,60,80,100,120,140] - the 8th
total for the spare cannot be calculated until the next throw.

best wishes, Isaac