^: does more than meets the eye - at least it used to, when I
last spent the time to check it out carefully.  Then, it
always checked to see if a result was equal to the previous
result; if so, it assumed that the result was not going to change
again, and stopped evaluating at that point.  That is needed for
^:_, and can terminate other powers
early as well.  It did one evaluation of the verb to initialize
the test (I never understood why, but I didn't look into it
very hard).

Roger put in special code, I think, for the cases ^:0 and ^:1,
so that they don't evaluate an extra time.  It looks like ,1
doesn't have the same speedup.

In any case, you can't be sure that ^:n will evaluate exactly
n times.

Henry Rich

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Fraser Jackson
> Sent: Thursday, June 08, 2006 6:18 AM
> To: Beta forum
> Subject: [Jbeta] Power with Vector argument - a bug?
> 
> The follwoing is clipped from a session:  It illustrates that 
> ^:(n) and 
> ^:(,n)
> appear to have a different effect.   (n beta Windows XP)
> 
>   INFO_base_ =: 0 2 $ 0
>    j =: scstep2 ^: 1  g0
>    INFO_base_
> _1034.96 880
> 
>    NB.  An item is added to global INFO_base_ with each call
> 
>    INFO_base_ =: 0 2 $ 0
>    j =: scstep2 ^: (,1)  g0
>    INFO_base_
> _1034.96 880
> _1034.96 880
>    INFO_base_ =: 0 2 $ 0
>    j =: scstep2 ^: 2  g0
>    INFO_base_
> _1034.96 880
>  2030.12 880
>    INFO_base_ =: 0 2 $ 0
>    j =: scstep2 ^: (,2)  g0
>    INFO_base_
> _1034.96 880
> _1034.96 880
>  2030.12 880
> 
> Duplication of the first item appears systematically for 
> vector arguments of 
> the power conjunction with the functions being used.
> 
> The follwoing minimal example which reproduces what I would 
> expect to be the 
> code elements important in this case does not reproduce the behaviour.
> 
> NB.  test exercise
> 
> t1 =: 4 : 0
> INFO_base_ =: 0 2$0
> sel^: (>:i.x)  y.
> )
> 
> sel =: 3 : 0
> v =. (>:{.y.), 1.1*{:y.
> INFO_base_ =: INFO_base_ , v
> v
> )
> 
>    INFO_base_ =: 0 2 $ 0
>    g0 =: 1 1.1
>    sel ^:(1) g0
> 2 1.21
>    INFO_base_
> 2 1.21
>    INFO_base_ =: 0 2 $ 0
>    sel ^:(,1) g0
> 2 1.21
>    INFO_base_
> 2 1.21
> 
> Any suggestions would be helpful.
> 
> Fraser
>  
> 
> ----------------------------------------------------------------------
> 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