({:,~ }:- }.)&.|: prm
0 8 5 22
6 5 9 40
4 3 0 40
6 64 0 0
0 85 0 0
155 0 0 0
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:programming-
> [EMAIL PROTECTED] Namens Devon McCormick
> Verzonden: donderdag 29 mei 2008 5:17
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] BegQ--Does a two-atoms-at-a-time verb/phrase
> exist?
>
> How about
>
> ]prm=. 35 35 27 22, 60 54 49 40, 47 43 40 40, 70 64 0 0,85 85 0 0,: 155
> 0
> 0 0
> 35 35 27 22
> 60 54 49 40
> 47 43 40 40
> 70 64 0 0
> 85 85 0 0
> 155 0 0 0
>
> ({:"1 prm),.~2-/\"1 prm
> 0 8 5 22
> 6 5 9 40
> 4 3 0 40
> 6 64 0 0
> 0 85 0 0
> 155 0 0 0
>
> The "({:"1 prm),.~" part appends the final column onto the end.
>
> The key here is that scan "\" takes both a derived function "-/" and a
> numeric argument "2" specifying the window to which the derived function
> applies; a negative numeric argument specifies non-overlapping windows.
>
> On Wed, 28 May 2008 21:51:08 -600, PackRat <[EMAIL PROTECTED]> wrote:
> >
> > I have an array of continually cumulating values in each row. What I'd
> > like to do is to create another array (or even using the *same* array
> > eventually saved under a different name) that, for each row, contains
> > the deltas (changes) between two columns at a time, sliding along. I
> > thought it'd be most convenient to reverse the columns in the array
> > (using |.) so that subtractions would be easier. I thought I could use
> > something like -/ but that didn't work at all since, no matter what I
> > did, it kept grouping the columns differently from what I wanted.
> > Here's a reversed array (left) and a derived array (right) showing the
> > end result I'm looking for:
> >
> > 35 35 27 22 0 8 5 22
> > 60 54 49 40 6 5 9 40
> > 47 43 40 40 --> 4 3 0 40
> > 70 64 0 0 6 64 0 0
> > 85 85 0 0 0 85 0 0
> > 155 0 0 0 155 0 0 0
> >
> > For example, what I'm looking for should do the following in the first
> > row, taking two columns at a time and sliding to the right:
> > 35 - 35 = 0 (is or replaces first column's value)
> > 35 - 27 = 8 (is or replaces second column's value)
> > 27 - 22 = 5 (is or replaces third column's value)
> > 22 = 22 (last column retains its value)
> >
> ...
>
>
> --
> Devon McCormick, CFA
> ^me^ at acm.
> org is my
> preferred e-mail
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm