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) Although I'm showing merely a 6x4 array, the "real" data has over 70,000 rows (increasing in number each time period), and the number of columns obviously increases by one as each time period passes. Ultimately, by again reversing the column order in the resulting array, I'd have an array showing a starting value and the succeeding value changes during the time period represented by each column. Is there an existing verb, function, or phrase that already does what I'm seeking? (I can see where what I'm asking is quite similar to many things in the business world, although in that case the columns might have both positive and negative values; that's why I'm thinking that code for such a technique might already exist.) If not, is using (slower) explicit loops (for rows and for columns within rows) the only practical way to accomplish this? Thanks in advance for any helps and insights into this problem! Harvey ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
