So far I have cleaned and shortened the code as:

scored=: adverb def (':'; '((x , +/@[) ; ])&>/ u y ')
andbonus=: conjunction def '(m+n)&{. ; m&}.'
openr=:2 andbonus 0
sparer=:2 andbonus 1
striker=:1 andbonus 2
rind=: 13 : '>:* 10-~ +/2{.y'
chooser=: [EMAIL PROTECTED]@] scored
doframe=: chooser&>/
upto10frames=: 10 > [: # [: > {.
game=: 13 : '+/ > {. doframe^:upto10frames^:_ '''';y'

However, I found out there was a failing case as:

strike_none_spare_case=: 10 0 10 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0
assert 34-:game strike_none_spare_case

It's because of rind is not strict enough. I have to correct it as:

rind=: monad define
if. 10-:{.y do.  NB. strike
  2
elseif. 10-:+/2{.y do.  NB. spare
  1
elseif. do.  NB. open
  0
end.
)

Now everything works all right.

However, I don't like the verbose definition. Is there conciser
definition that does a similar job?

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

Reply via email to