It makes a significant difference if you "put the data back",
i.e. do the operation in place:

   10 ts 'ii reverse`[`]}xx'
0.0131137 4.1968e6
   10 ts '(ii reverse xx) ii}xx'
0.0127947 4.19597e6
   10 ts 'xx=: (ii reverse xx) ii}xx'
1.00851e_5 1792

The last benchmark would be the goal for the prospective special
code for the following:

   10 ts 'xx=: ii reverse`[`]}xx'
0.0136649 4.19686e6

But perhaps the special code is not needed?  There isn't 
much difference between the two:

xx=: (ii reverse xx) ii}xx
xx=: ii reverse`[`]}xx

Not enough to justify a lot of work and more specialness.



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

> On 7/12/06, R&S HUI <[EMAIL PROTECTED]> wrote:
> > 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).
> 
> i do gather that special code does not like "cover functions". But
> currently the flexibility/generality offered by the namings does not
> seem to make a significant difference:
> 
>   ii=:(1 2; 2 0)
>   xx=:i. 999 999
>   10 Ts 'ii reverse`[`]} xx'
> 0.0163818 4.1968e6
>   10 Ts 'ii ([:|.{)`[`]} xx'
> 0.0192198 4.19686e6
>   10 Ts 'ii reverse amend xx'
> 0.0194623 4.19674e6
>   10 Ts 'ii swapG xx'
> 0.0159129 4.19578e6
> 
> i had been hoping there might be a more efficient way of doing 
> what i
> was doing...
> 
> Is there some prospect for special coding for this more generic swap
> functionality? i would certainly forgo the perspicuity and generality
> if there were such a prospect - though i dislike such hard coding
> which is hard to maintain and read. It is a significant time sink in
> my app.


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

Reply via email to