Tacitly...

   foo=. (&.>)/\.(&.|.)(@:([ ; _4 <\ ])) (;@:)
   3 ([: (+/ % #) ,)foo i.20
3 1.8 4.76 8.552 12.5104 16.50208






On Wed, Dec 3, 2014 at 5:03 AM, R.E. Boss <[email protected]> wrote:

> Equivalent to boxscan with u=: [: (+/%#),  is
>
>     ;([: (+/%#),)&.>/\. &.|.3;_4 <\i.20
> 3 1.8 4.76 8.552 12.5104 16.50208
>
> or as adverb
>
>    foo=:1 : ('';':';'; u &.>/\.&.|.x;_4<\y')
>
>    3 ([:(+/%#),) foo i.20
> 3 1.8 4.76 8.552 12.5104 16.50208
>
>
> R.E. Boss
>
>
> > -----Original Message-----
> > From: [email protected] [mailto:programming-
> > [email protected]] On Behalf Of Jon Hough
> > Sent: woensdag 3 december 2014 3:10
> > To: [email protected]
> > Subject: Re: [Jprogramming] Modifying x inside Infix
> >
> > I do not think updating y is what I need in this case.In pseudocode, an
> > example is
> > x = 3; //just some start value for xy; //some arrayfor (i = 0; i < max;
> i+= 4){
> >       x = myVerb(x, y[i], y[i+1], y[i+2], y[i+3]); //my verb is
> > equivalent(~ish) to  verb u.}
> > return x;
> > So I thought using u\ would be a good way to do the forloop. The problem,
> of
> > course, is that the previous iteration's result of myVerb is the next
> iterations
> > myVerb parameter.
> > I'm not wedded to the idea of using u\, and I am beginning to wonder if
> it
> is
> > completely inappropriate for doing this.
> > > Date: Wed, 3 Dec 2014 01:27:39 +0000
> > > From: [email protected]
> > > To: [email protected]
> > > Subject: Re: [Jprogramming] Modifying x inside Infix
> > >
> > > The argument to 4 u\ y will be entirely y, and u is monadic.
> > >
> > > you can do something like this though:
> > >
> > > 2 (3&+)\ i.5
> > > 3 4
> > > 4 5
> > > 5 6
> > > 6 7
> > >
> > >
> > > If you can change your spec to "updating y" on every iteration, and you
> > want to apply to:
> > >
> > > x1 u (x2 u y)
> > > then you can make a table where x1, x2 and y are the 3 rows, and then
> call
> > with u/.  You can search for boxscan in archives for method where x and y
> are
> > not the same shape.  This is generally preferable to trying to keep a
> side
> > effect between calls (so you don't need to worry about initializing it)
> > >
> > >
> > > ________________________________
> > > From: Jon Hough <[email protected]>
> > > To: "[email protected]" <[email protected]>
> > > Sent: Tuesday, December 2, 2014 7:58 PM
> > > Subject: [Jprogramming] Modifying x inside Infix
> > >
> > >
> > > If y is a list and I have a dyadic verb u, which I want to apply to
> every 4 items
> > of y I can do
> > >
> > > x ( 4 u \) y
> > >
> > >
> > > and this will apply x u to every 4 items.
> > >
> > >
> > > But I want to continually update x every iteration. So after doing x u
> y
> to
> > the first 4 items, x becomes the result,
> > >
> > >
> > > i.e. x =: x u y
> > >
> > >
> > > How do I do this for all the list?
> > >
> > >
> > > I tried things like
> > > result =:  leftArg ( 4 (leftArg =:) u \ )rightArg
> > >
> > >
> > > but I can't get the correct syntax (assuming there is a way to do
> this).
> > > (I hope my explanation made sense.)
> > > Thanks.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > ----------------------------------------------------------------------
> > > 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