I suggest you try the benchmarks in
http://www.jsoftware.com/jwiki/Essays/Index_in_Nub
in APL.

Another one in the same vein is  /:/:y  to find the
rankings of y .  The grade on the left is often
avoided in APL because it takes n log n time whereas
the equivalent
   i=. /: y
   z=. (#y)$2
   (i.#y) i}z
is linear in the second part.  In APL it's
   i{is}{gradeup}y
   z{is}({rho}y){rho}2
   z[i]{is}{iota}{rho}y
In J you just do  /:/:y  because grade on small 
range integers takes linear time.

There is also the "special code" in J.  
http://www.jsoftware.com/help/dictionary/special.htm
The J architecture makes it straightforward to 
"recognize" tacit expressions and provide efficient 
implementations of them.  e.g.

   y=: 1e6 [EMAIL PROTECTED] 1e6
   5e5 (< i. 1:) y
3

Index of the first item of y greater than 5e5.

   ts=: 6!:2 , 7!:[EMAIL PROTECTED]
   ts '5e5 (<i.1:) y'
9.77778e_6 1216
   ts '(5e5<y)i.1'
0.00713191 1.04934e6

In APL there is no recourse but to do (5e5<y)i.1 .



----- Original Message -----
From: [EMAIL PROTECTED]
Date: Friday, June 1, 2007 7:46 am
Subject: Re: [Jgeneral] Re: Challenge to expert J'ers

> OK>   (/:@({~ i.~) -: tgu3) x
> 1
> 
> I am in a state of shock ! 
> Roger ! I can't believe my eyes on the difference in speed of the 
> i. 
> implementation versus dyadic iota in APL why is it so ? 
> 
> I would qualify Oleg's solution as the "pure J" solution and it 
> should be 
> the "pure APL" solution too but...
> 
> Oleg's solution can't be implemented in APL because it is about 
> 323 
> seconds with an x which is ten times smaller. No APL'er I know 
> would have 
> taken this simple approach because they are brain damaged by their 
> APL 
> implementation.
> 
> History: Us APL'ers have been influenced by the quality of 
> implementations 
> of APL interpreters. It would have never crossed my mind to use 
> dyadic 
> iota (i. for J'ers) in such a straight forward manner. Why ? 
> Because it is 
> slow as a dog in all APL interpreters I currently know.
> 
> I remember several conversations with various APL'ers about how 
> some 
> "motivated newbies" wanted to implement a "faster dyadic iota" 
> rather than 
> doing the "right thing" and move forward... Or was it really 
> backward ?
> 
> Conclusion: Even older APL'ers have to understand the influences 
> of the 
> implementations they worked on and they should throw all that 
> knowledge 
> away because J's implementation makes it really clear that the 
> particulars 
> of any/all APL interpreters have short-circuit their brain away 
> from the 
> simplicity of the language.
> 
> NB. I am so shocked that I am preparing a white paper on this very 
> issue 
> for our APL team. The title could be:
> "How APL implementations have ruined your pure APL thinking and 
> why J can 
> restore it..."
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to