Oh, sorry. You don't need to box and unbox in toframe:
toframe=: [: }: [: (fence/)@|.\ 1 , 10 > ]
On 3/27/06, June Kim <[EMAIL PROTECTED]> wrote:
> I used your scores verb and tenframes verb:
>
> shift=:|.!.0
> fence=:[: -. *.
> tenframes=:(*.10 >: +/\)
> toframe=:[: > [: }: [: <@(fence/)@|.\ 1 , 10 > ]
> frame2=:[EMAIL PROTECTED]
> scores=: (2 shift ]) (] + [ * 10 <: ]) frame2 * ] + 1 shift ]
>
> empty_case=: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> open_case=: 9 0 8 1 7 2 6 3 5 4 4 5 3 6 2 7 8 1 0 9
> spare_case=: 9 1 8 2 7 3 6 4 5 5 4 6 3 7 2 8 1 9 8 2 1
> strike_case=: 10 10 10 10 10 10 10 10 10 10 10 10
> alt_case=: 9 1 10 8 2 10 7 3 10 6 4 10 5 5 10 4 6
> none_and_spare_case=:0 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>
> NB. note that the last 10 is dropped from alt_case
> NB. you can't throw more than 3 times in the last frame
> NB. the initial input data was wrong
>
> assert 0=+/scores empty_case
> assert 90=+/scores open_case
> assert 145=+/scores spare_case
> assert 300=+/scores strike_case
> assert 200=+/scores alt_case
> assert 30=+/scores none_and_spare_case
>
> On 3/27/06, Miller, Raul D <[EMAIL PROTECTED]> wrote:
> > June Kim wrote:
> > > Thank you for the solution but it doesn't seem to work right.
> > >
> > > none_and_spare_case=:0 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NB. 30
> >
> > Oops, my mistake.
> >
> > I guess I need to do this the hard way:
> > frame=: [:(*.11>+/\)@|[EMAIL PROTECTED](1((1:`([EMAIL PROTECTED]:)@.([EMAIL
> > PROTECTED])@],{:@[),.])/@,.])@|.
> >
> > That should be unwrapped onto one line, and replaces my
> > erroneous concept of a frame. It should also be run through
> > J's linear rep to introduce some needed whitespace -- making
> > it more readable.
> >
> > For that matter, it's complex enough that I should probably convert
> > it to an explicit definition. An explicit definition can make better
> > use of vertical whitespace and which I think tends to make this sort
> > of thing more readable.
> >
> > Or, I should break that definition out into several words. Perhaps
> > four pieces: the part that sets up for the main reduce operation,
> > the reduce operation itself (without the reduce operator), the part
> > that post-processes that result, and finally the "frame" verb which
> > combines these pieces. Something like:
> >
> > F1=: 1 ,. |.
> > F2=: (1:`(10 = [EMAIL PROTECTED]:)@.([EMAIL PROTECTED])@] , {:@[) ,. ]
> > F3=: (*. (11 > +/\))@|[EMAIL PROTECTED]
> > frame=: [: F3 [: F2/ F1
> >
> > The heart of this operation, F2, assembles a state history
> > where the top row is the bit that marks the beginning of a
> > frame, and the bottom row is the number of pins which were
> > knocked down in that set (which is needed in determining
> > whether the next ball begins a new frame).
> >
> > What I think I really want for this kind of thing is an
> > operator which has some of the characteristics of a
> > tesselation like dyadic \ or ;. and some of the characteristics
> > of an iteration operator like /
> >
> > Maybe if I thought a bit more, something obvious would occur to
> > me about this.
> >
> > Thanks,
> >
> > --
> > Raul
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm