If the grand total verb is likely to need different definitions for
different contexts, I think it makes even more sense to define it
separately from the subtotal verb.

-- 
Raul

On Tue, Sep 11, 2012 at 9:54 AM, Robert Cyr <robert....@gmail.com> wrote:
> Thank you Raul.
>
> As for gt,  there are often multiple levels of sub-totals, requiring a
> loop, , or perhaps a recusrsive form.
>
> Your point on reserved words is well taken.
>
> Robert
>
> On Mon, Sep 10, 2012 at 4:06 PM, Raul Miller <rauldmil...@gmail.com> wrote:
>
>>    gt=: ([#_:), +/@:(}."1)
>>    M=: mt,gt
>>
>> --
>> Raul
>>
>> P.S. I do not like using reserved names globally (m,n,u,v,x,y).
>>
>> On Mon, Sep 10, 2012 at 3:00 PM, Robert Cyr <robert....@gmail.com> wrote:
>> > As a first step in analyzing data it is nice to have subtotals by
>> different
>> > parameters.  I guess for example one could get total salaries, costs and
>> > sales totaled for an entire country and subtotaled by region, sex, age
>> of a
>> > sales-force.  Each sale can then be included in an array of 6 columns in
>> > this case.  Each subtotal would be produced with:
>> >
>> > mt=:(/:~)@(([:~.{."1 ),.{."1 +//. }."1)
>> >
>> > In our case,
>> >
>> > 3 mt (a: 6-column array)
>> >
>> > would produce all sub-totals. But for all levels of sub-totals as well as
>> > the grand total, the following would do:
>> >
>> > m=: 4 : 0
>> >  w=. (0,{:$y)$0
>> >  u=.y
>> >  for_t. i.-x+1 do.
>> >   u=. t mt u
>> >   if. t < x do. u=. _ (<a:;t)}u end.
>> >  w=.w,u
>> >  end.
>> >  /:~w
>> > )
>> >
>> > on my iPad, i get:
>> >   ts'4 m ?.1000000$,: 4 5#5 100'
>> > time:    4.39185
>> > space: 1.97136e8
>> >
>> > But I have not ben lucky wit a one-liner on this, I tried:
>> >
>> >     3    (}.@])`(($:<:@[)(],mt)])@.(0<[)a
>> > |stack error
>> > |   3    (}.@])`(($:<:@[)(],mt)])@.(0<[)a
>> >
>> > Expecting to substitute mt into this line and get a mean one-liner.
>> >
>> > Any hints or suggestion?
>> >
>> > Robert Cyr
>> >
>> >
>> > Sent from my iPad
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to