2007/1/31, June Kim <[EMAIL PROTECTED]>:
2007/1/31, R.E. Boss <[EMAIL PROTECTED]>:
> Initially you wrote:
>
> > The size of the window is always odd.
>
> but apparently that holds for the maximum window only.
> I thought all windows should be of odd length. Because with windows of even
> length it's hard to determine a middle point.

Oh, that was the misconception. Sorry.

I should've written instead, the size of the window as given is always
odd. That is, the size of the maximum window(the x of the verb sw) is

I meant "the y of the verb sw". Sorry for the typo.

always odd. "d sw 4" would never happen.



>
> Apart from that, you wrote
>
> > 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
>
> IMO, for the first and last 2 windows that is rather inconsistent.
>

The position of the window is at 0, when starting. The maximal size of
the window is 5 and the window stretches to include only 3 items,
since there are no elements on the left side of the center point(which
is 5).

When the position of the window reaches the last item(3), it tries to
stretch to include as many as 5 elements residing still at the last
item as the center. Since there are no elements on the right side of
3, which is middle, the window stops streching.

>
> R.E. Boss
>
>
>
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Namens June Kim
> Verzonden: woensdag 31 januari 2007 13:01
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] sliding window
>
> 2007/1/31, R.E. Boss <[EMAIL PROTECTED]>:
> > Shouldn't your result be
> >
> > 5; 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; 3
> >
> > where the 5 at the start and the 3 at the end are added?
>
> No. But Thanks anyway.
>
> Let me try the definition again.
>
> The maximum of the window's size is given. When possible the window
> should be as large as possible but not larger than its given maximum
> size. The moving window's position is its center point. When the given
> list is of size N, the number of windows should be N, too. The
> window's position(center) starts from at index 0 of the list. The
> window moves its position(center) by one to the right, until the
> center point reaches the end of the list.
>
>
> > They are the centre of a window of 1.
> > This is also in accordance with the middle points you gave: 5, 10, 7 ...,
> 4,
> > 3
> >
> > But then the solution is simple:
> >        the middle points are given by d
> >        and the lengths of the windows are given by
> >
> >   <./5,(,:|.)(+:+1:)i.#d
> > 1 3 5 5 5 5 5 5 5 3 1
> >
> >
> > If you want the windows boxed then
> >
> >   5(<;._3 ([EMAIL PROTECTED],[,{:@]) ((,:-@|.)@(2&|#])@[EMAIL PROTECTED]) 
(<@{."0 _)"1 ]) d
> >
> +-+------+----------+----------+---------+-----------+------------+---------
> > ---+------------+------+-+
> > |5|5 10 7|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|_1 4 3|3|
> >
> +-+------+----------+----------+---------+-----------+------------+---------
> > ---+------------+------+-+
> >
> > is a (first) solution, with thanks to McCormick who brought up <;._3
> >
> > R.E. Boss
> >
> >
> >
> > -----Oorspronkelijk bericht-----
> > Van: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] Namens June Kim
> > Verzonden: woensdag 31 januari 2007 2:39
> > Aan: Programming forum
> > Onderwerp: [Jprogramming] sliding window
> >
> > 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
> >
> > ----------------------------------------------------------------------
> > 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

Reply via email to