When you look at the two trees, it seems that c01 should take longer as there 
must be some extra code to produce a 1:

c0=:,@((1 0 1 */ ])^:(]`(1"_)))
   c01=:,@((1 0 1 */ ])^:(]`1:))
   
   c0
      ┌─ ,                 
      │        ┌─ 1 0 1    
── @ ─┤      ┌─┼─ / ───── *
      │      │ └─ ]        
      └─ ^: ─┤             
             │ ┌─ ]        
             └─┤       ┌─ 1
               └─ " ───┴─ _
   c01
      ┌─ ,                 
      │        ┌─ 1 0 1    
── @ ─┤      ┌─┼─ / ───── *
      │      │ └─ ]        
      └─ ^: ─┤             
             │ ┌─ ]        
             └─┴─ 1:       
Linda


-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of Henry Rich
Sent: Friday, December 1, 2017 10:23 PM
To: [email protected]
Subject: Re: [Jprogramming] APL Exercises

I see what's happening.  1"_ produces a Boolean, while 1: produces an integer.  
In this case the Boolean is better.  I'm not sure whether it always would be; 
what do you think?

Henry Rich

On 12/1/2017 9:12 AM, Raul Miller wrote:
> Huh...
>
> I can reproduce that 10x speed difference:
>
>     timespacex 'c0 17'
> 0.078233 2.01328e8
>     timespacex 'c01 17'
> 0.761976 1.61061e9
>     c0
> ,@((1 0 1 */ ])^:(]`(1"_)))
>     c01
> ,@((1 0 1 */ ])^:(]`1:))
>
> This seems bizarre.
>
> Thanks,
>


---
This email has been checked for viruses by AVG.
http://www.avg.com

----------------------------------------------------------------------
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