APL way ...
a ; (_1&}. - 1&}.)"1 a,"1]0
+------------+-----------+
| 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|
+------------+-----------+
Or using J Infix ...
a ; 2-/\"1 a,"1]0
+------------+-----------+
| 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|
+------------+-----------+
Rob Hodgkinson
On 29/05/08 1:51 PM, "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 information about J forums see http://www.jsoftware.com/forums.htm