I wrote:
>          13 : 'y i. >./ y'
>       ] i. >./
>       
>          rand =: ?~ 3e6
>          
>          (-: |.)@:(ways`:0) rand  NB.  Identical results
>       1
>       
>          '5.2d' 8!:2 (%"1 <./) (6!:2, 7!:2@:])&> ways ,L:0 ' rand'  NB.  
> Non-identical performance
>        5.06 1.07
>        5.09 1.07
>        1.00 1.00


Sorry, I forgot to include the definition of "ways" (the heart of the example):

           w0 =: 13 : 'y i. >./ y'
           w1 =: ] i. >./
           w2 =: i. >./
           ways =: w0`w1`w2

That is, the tacit output of  13 :  is significantly slower than the native 
tacit code (which is often true of any code generator or
automatic translator).  In fact, it is just as slow as the original explicit 
code:

          w_1  =:   3 : 'y i. >./ y'
          w0   =:  13 : 'y i. >./ y'
          w1   =:  ] i. >./
          w2   =:  i. >./
          ways =:  w_1`w0`w1`w2
        
          rand =: ?~ 3e6
          
          (-: |.)@:(ways`:0) rand  NB.  Identical results
        1
        
          '5.2d' 8!:2 (%"1 <./) (6!:2, 7!:2@:])&> ways ,L:0 ' rand'  NB.  
Non-identical performance
         4.47 2.86
         4.60 1.07
         4.45 1.07
         1.00 1.00

Though it does have a space advantage (which surprises me).  

-Dan

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

Reply via email to