The prospects for more efficient computation improves if you say
   name=: x u@:{`[`]} name      NB. (0)
   name=: x u`[`]} name         NB. (1)
instead of
   name=: x reverse amend name  NB. (2)
   name=: x |.@:{ amend name    NB. (3)

It is easier and more productive for the prospective special 
code to handle (0) and (1) than (2) or (3).  



----- Original Message -----
From: greg heil <[EMAIL PROTECTED]>
Date: Wednesday, July 12, 2006 1:15 pm
Subject: Re: [Jprogramming] special coding for stack operations

> On 7/12/06, R&S HUI <[EMAIL PROTECTED]> wrote:
> > What exactly is "swap"?  Is it  name=: (<i,j) C. name  ?
> 
> In this context it is as
> 
> On 7/12/06, Miller, Raul D <[EMAIL PROTECTED]> wrote:
> > Using the right hand edge of a list as top of stack:
> >    swap=: _2 (}. , |[EMAIL PROTECTED]) ]
> 
> However it is interesting you asked, as i have been trying to develop
> an efficient generalization, which i have been calling swap, that
> reverses arbitrary elements in an array. Eg defined as
> 
> reverse=:[:|.{        NB. reverse of x{y
> amend=: 1 : 'u`[`]}'  NB. amend x{y with u of x{y
> swapG=: reverse amend
>   (1 2; 2 0) swapG i.4 4
> 0  1  2  3
> 4  5  8  7
> 6  9 10 11
> 12 13 14 15
> 
> But i am not clear on how to make this operation efficient, it is
> currently a major fraction of the time budget for my application...


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to