> From: Tracy Harms
> Sent: Sunday, 3 May 2009 12:32
>
> scoregame =: verb define
> tens =. 10&= # i...@#
> frame=. verb :'(#~ _1&~:)&.> _2<\ y #!._1~ 1j1 (ix #~ 2 ~:/\ 1,
> 2|ix=.tens y) } 1#~#y'
> bonus1 =. 10=+/
> bonus2 =. 10={.
> scores =. [: > {.
> unscored=. }.
> laterballs=. verb :'2 {. ; }.y'
> framepins =. [: > {.
> bonus=. laterballs * [:(bonus1, bonus2) framepins
> oneframe=. [: +/ framepins, bonus
> scoreheadframe=. ([: < scores, [:oneframe unscored) , 2}.]
> +/ >{. scoreheadframe^:10 (a:,frame) y
> )
>
> testballs=: 0 10, 4 4, 5 5, 9 1, 8 1, 10, 10, 0 10, 1 9, 10 10 3
If you try to define and test this in a fresh session:
scoregame testballs
|value error: tens
| (#~_1&~:)&.>_2<\y#!._1~1j1(ix#~2~:/\1,2|ix=. tens y)}1#~#y
This is because the tens verb is defined locally to the scoregame verb and
therefore isn't available inside the frame verb.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm