Handy

On Tue, Oct 6, 2015 at 6:15 PM, Kip Murray <[email protected]> wrote:

> This is what I wanted to send. --Kip Murray
>
> NB. A way to do column operations
>
> NB. rop below makes row 2 become cumulative total of row 1
>
> rop =: (2 {. ]),([: +/\ 1 { ]), 3 }. ]
>
> NB. cop below makes col 2 become cumulative total of col 1
>
> cop =: rop&.|:
>
> NB. Example
>
> ]sheet =: i. 5 4
> 0 1 2 3
> 4 5 6 7
> 8 9 10 11
> 12 13 14 15
> 16 17 18 19
>
> rop sheet
> 0 1 2 3
> 4 5 6 7
> 4 9 15 22
> 12 13 14 15
> 16 17 18 19
>
> cop sheet
> 0 1 1 3
> 4 5 6 7
> 8 9 15 11
> 12 13 28 15
> 16 17 45 19
>
> On Tue, Oct 6, 2015 at 6:08 PM Kip Murray <[email protected]> wrote:
>
> > Apologies for the mess below -- ill-behaving mailer! --Kip Murray
> >
> > On Tue, Oct 6, 2015 at 6:05 PM Kip Murray <[email protected]>
> wrote:
> >
> >> <div style="color: rgb(0, 0, 0); font-family: 'Courier New'; font-size:
> >> 18px; font-style: normal; font-variant: normal; font-weight: normal;
> >> letter-spacing: normal; orphans: auto; text-align: left; text-indent:
> 0px;
> >> text-transform: none; white-space: normal; widows: auto; word-spacing:
> 0px;
> >> -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">   NB.
> A
> >> way to do column operations</div><div style="color: rgb(0, 0, 0);
> >> font-family: 'Courier New'; font-size: 18px; font-style: normal;
> >> font-variant: normal; font-weight: normal; letter-spacing: normal;
> orphans:
> >> auto; text-align: left; text-indent: 0px; text-transform: none;
> >> white-space: normal; widows: auto; word-spacing: 0px;
> >> -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">
> >>  </div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">   NB.
> rop
> >> below makes row 2 become cumulative total of row 1</div><div
> style="color:
> >> rgb(0, 0, 0); font-family: 'Courier New'; font-size: 18px; font-style:
> >> normal; font-variant: normal; font-weight: normal; letter-spacing:
> normal;
> >> orphans: auto; text-align: left; text-indent: 0px; text-transform: none;
> >> white-space: normal; widows: auto; word-spacing: 0px;
> >> -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">
> >>  </div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">   rop
> =:
> >> (2 {. ]),([: +/\ 1 { ]), 3 }. ]</div><div style="color: rgb(0, 0, 0);
> >> font-family: 'Courier New'; font-size: 18px; font-style: normal;
> >> font-variant: normal; font-weight: normal; letter-spacing: normal;
> orphans:
> >> auto; text-align: left; text-indent: 0px; text-transform: none;
> >> white-space: normal; widows: auto; word-spacing: 0px;
> >> -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">
> >>  </div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">   NB.
> cop
> >> below makes col 2 become cumulative total of col 1</div><div
> style="color:
> >> rgb(0, 0, 0); font-family: 'Courier New'; font-size: 18px; font-style:
> >> normal; font-variant: normal; font-weight: normal; letter-spacing:
> normal;
> >> orphans: auto; text-align: left; text-indent: 0px; text-transform: none;
> >> white-space: normal; widows: auto; word-spacing: 0px;
> >> -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">
> >>  </div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">   cop
> =:
> >> rop&amp;.|:</div><div style="color: rgb(0, 0, 0); font-family: 'Courier
> >> New'; font-size: 18px; font-style: normal; font-variant: normal;
> >> font-weight: normal; letter-spacing: normal; orphans: auto; text-align:
> >> left; text-indent: 0px; text-transform: none; white-space: normal;
> widows:
> >> auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> >> 0.301961); -webkit-text-size-adjust: none; -webkit-text-stroke-width:
> >> 0px;">   </div><div style="color: rgb(0, 0, 0); font-family: 'Courier
> New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">   NB.
> >> Example</div><div style="color: rgb(0, 0, 0); font-family: 'Courier
> New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">
> >>  </div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">
>  ]sheet
> >> =: i. 5 4</div><div style="color: rgb(0, 0, 0); font-family: 'Courier
> New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;"> 0  1
> 2
> >>  3</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;"> 4  5
> 6
> >>  7</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;"> 8  9
> 10
> >> 11</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">12 13
> 14
> >> 15</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">16 17
> 18
> >> 19</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">
> >>  </div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">   rop
> >> sheet</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;"> 0  1
> 2
> >>  3</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;"> 4  5
> 6
> >>  7</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;"> 4  9
> 15
> >> 22</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">12 13
> 14
> >> 15</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">16 17
> 18
> >> 19</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">
> >>  </div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">   cop
> >> sheet</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;"> 0  1
> 1
> >>  3</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;"> 4  5
> 6
> >>  7</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;"> 8  9
> 15
> >> 11</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">12 13
> 28
> >> 15</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">16 17
> 45
> >> 19</div><div style="color: rgb(0, 0, 0); font-family: 'Courier New';
> >> font-size: 18px; font-style: normal; font-variant: normal; font-weight:
> >> normal; letter-spacing: normal; orphans: auto; text-align: left;
> >> text-indent: 0px; text-transform: none; white-space: normal; widows:
> auto;
> >> word-spacing: 0px; -webkit-tap-highlight-color: rgba(26, 26, 26,
> 0.301961);
> >> -webkit-text-size-adjust: none; -webkit-text-stroke-width: 0px;">
> >>  </div><br class="Apple-interchange-newline">
> >>
> >> On Tue, Oct 6, 2015 at 5:55 PM John Baker <[email protected]> wrote:
> >>
> >>> Not at all. I often transpose but in this case the table has less than
> >>> 1000 rows so it's not a large amount of data.
> >>>
> >>>
> >>> Sent from my iPhone
> >>>
> >>> > On Oct 6, 2015, at 5:14 PM, Raul Miller <[email protected]>
> wrote:
> >>> >
> >>> > Rather than using a rank 1 operation, I'd prefer to use a
> >>> > column-at-a-time approach (in other words: transpose the table before
> >>> > working on it).
> >>> >
> >>> > I think that performance should be better, and the expressions are
> >>> > easier (in my opinion) to create.
> >>> >
> >>> > Ndx=: 3 :0"0
> >>> >  {. y&{::`''
> >>> > )
> >>> >
> >>> > ColNdxs=: 3 :0
> >>> >  #('`',y)=: Ndx i.#;:y
> >>> > )
> >>> >
> >>> >   ColNdxs 'A B C D E F G H I J K L M N O P Q'
> >>> > 17
> >>> >
> >>> >   (((A * B) + C) - ((F - G) * (Q + B))) |:i.5 17
> >>> > 19 376 1311 2824 4915
> >>> >
> >>> > Does this approach create problems for you?
> >>> >
> >>> > Thanks,
> >>> >
> >>> > --
> >>> > Raul
> >>> >
> >>> >
> >>> >> On Tue, Oct 6, 2015 at 2:16 PM, John Baker <[email protected]>
> >>> wrote:
> >>> >> The other day I was converting spreadsheet formulas that applied
> >>> between
> >>> >> columns to J operations on numeric tables.
> >>> >>
> >>> >> One such formula was:
> >>> >>
> >>> >> ((I - E) + R) - D
> >>> >>
> >>> >> Where the verbs -,+ work on columns. To convert this to a simple J
> >>> >> expression you can "Iversonize".
> >>> >>
> >>> >> D -~ R + E -~ I
> >>> >>
> >>> >> which leads directly to the nice little verb (cops):
> >>> >>
> >>> >> cops=:  -~`+`(-~)`:3"1
> >>> >>
> >>> >> That will do all the operations on each row in one swoop.
> >>> >>
> >>> >> The question arises. Given an arbitrary parenthesized formula with
> >>> only
> >>> >> dyadic verbs as text:
> >>> >>
> >>> >> '((A * B) + C) - ((F - G) * (Q + B))'
> >>> >>
> >>> >> Return the  Iversonized gerund expression and the column permutation
> >>> needed
> >>> >> to get an expression like (cops).
> >>> >>
> >>> >> I've been doing this by hand but if anyone cares to dig into this
> and
> >>> crank
> >>> >> out a solution if would help many of us that are punished by
> >>> spreadsheets.
> >>> >>
> >>> >> --
> >>> >> John D. Baker
> >>> >> [email protected]
> >>> >>
> ----------------------------------------------------------------------
> >>> >> 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
>



-- 
John D. Baker
[email protected]
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to