Hmm, I don't understand exactly what is is that you don't understand :-).

The design of n f\ y came about as follows.  The concept of "moving window"
is well-known (moving average, moving maximum, etc.).  When n is a positive
integer, the interpretation is "obvious":

   4 <\ 'abcdefg'
┌────┬────┬────┬────┐
│abcd│bcde│cdef│defg│
└────┴────┴────┴────┘
   3 <\ 'abcdefg'
┌───┬───┬───┬───┬───┐
│abc│bcd│cde│def│efg│
└───┴───┴───┴───┴───┘

In n f\y, the function f is applied to each window of size n.  The windows
overlap and move by 1 each time.

When n is a negative integer, the definition is that the windows are of
size -n and do not overlap.  One of the anticipated uses is exactly the one
you need, where you have a vector and you want to make it into a matrix
with -n columns.

   _4 <\ 'abcdefg'
┌────┬───┐
│abcd│efg│
└────┴───┘
   _3 <\ 'abcdefg'
┌───┬───┬─┐
│abc│def│g│
└───┴───┴─┘
   _4 ]\ 'abcdefg'
abcd
efg
   _3 ]\ 'abcdefg'
abc
def
g



On Tue, Oct 9, 2012 at 5:46 AM, Dr. Heinz Schild <
[email protected]> wrote:

> Thank you for the very elegant formulation.
> However, why "_2" works as it does, I do not understand.
>
>
> Am 08.10.2012 um 20:10 schrieb Roger Hui <[email protected]>:
>
> > _2 ]\ 0".jfromcb '' may work, depending on your views on how an odd
> > number of input numbers should be handled.
> >
> >
> >
> > On Mon, Oct 8, 2012 at 11:00 AM, Dr. Heinz Schild
> > <[email protected]> wrote:
> >> I want to read a list with coordinates (x, y) of unknown length from
> the clipboard into an iPad and transform it into a table with 2 columns.
>  The following line works:
> >> ((<.-:# Zi),2)$ Zi=. 0". jfromcb ''
> >> But is  there a better way using only a tacit formulation?
> >> Heinz
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to