I may not fully understand what you want, but this satisfies the example:
   d=: 5 10 7 8 9 2 1 100 _1 4 3
   5<;._3 d NB. Almost does it except for the funny ends
+----------+----------+---------+-----------+------------...
|5 10 7 8 9|10 7 8 9 2|7 8 9 2 1|8 9 2 1 100|9 2 1 100 _1...
+----------+----------+---------+-----------+------------...
  ans=. 5 10 7; 5 10 7 8; 5 10 7 8 9; 10 7 8 9 2; 7 8 9 ...
  ans-:((_2 _1}.&.>2${.),],1 2}.&.>2${:) 5<;._3 d
1

Most of the work is futzing with the 2 short ones at either end.

On 1/30/07, June Kim <[EMAIL PROTECTED]> wrote:

Suppose the following data is given

   d=: 5 10 7 8 9 2 1 100 _1 4 3

Now suppose a verb that moves a sliding window through the data

   d sw 5

The size of the window is always odd. For each item in the given data,
the window should locate it at the middle point of the window. For
some items that's nearby boundaries, the window size could be smaller
than the given.

The result should be

5 10 7; 5 10 7 8; 5 10 7 8 9; 10 7 8 9 2; 7 8 9 2 1; 8 9 2 1 100; 9 2
1 100 _1; 2 1 100 _1 4; 1 100 _1 4 3; 100 _1 4 3; _1 4 3

Middle points for the window are 5, 10, 7 ..., 4, 3

What is an easy way for sw?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm




--
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to