Here's a cleaner way of expressing the bowling scorer:

shift=:|.!.0
frame=: (*.10 >: +/\)@(10&= +. [: ~:/\ 10>])
scores=: (2 shift ]) (] + [ * 10 <: ]) frame * ] + 1 shift ]

As before, the total score is +/@scores pins (where pins is
the number of pins knocked down by the ball).

Note that the result of this "scores" verb is organized
differently from that of the first one I posted.  The first
one I posted rates the score for each ball.  This one rates
the score for each frame (and scores non-frame balls as zero
points).

-- 
Raul

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to