“probably, earlier versions of J). “ :

FWIW,  on this iPad,  running J701,  so changing {{}} to 3 : 0 .... ), 
(and pritchard to pritch!),  I get the same results.

Mike

Sent from my iPad

> On 27 Aug 2022, at 02:51, Raul Miller <[email protected]> wrote:
> 
> I'm seeing strange behavior with sparse arrays, and I have been mostly
> unsuccessful in simplifying code exhibiting the problem. Thus:
> 
> pritch=: {{
>  spokes=. $.,1
>  primes=. i.0
>  while. y > #spokes do.
>    primes=. primes, p=. 2+(}.spokes) i.1 NB. find next prime
>    rim=. #spokes NB. "length" of "circumference" of wheel
>    spokes=. (y<.p*rim)$spokes NB. roll next larger wheel
>    spokes=. 0 ((#~ y>])_1+p*1+i.rim)} spokes
>  end.
>  NB. elided code here
>  primes,1+}.,I.spokes
> }}
> 
>   pritchard 20
> 2 3 5 7 11 13 17 19
> 
> pritch8=: {{
>  spokes=. $.,1
>  primes=. i.0
>  while. y > #spokes do.
>    primes=. primes, p=. 2+(}.spokes) i.1 NB. find next prime
>    rim=. #spokes NB. "length" of "circumference" of wheel
>    spokes=. (y<.p*rim)$spokes NB. roll next larger wheel
>    spokes=. 8 $. 0 ((#~ y>])_1+p*1+i.rim)} spokes
>  end.  NB. elided code here
>  primes,1+}.,I.spokes
> }}
>   pritch8 20
> 2 2 3 5 7 11 13 17 19
> 
> Somehow the value for p is different when 8 $. is present in this
> particular implementation (though I don't observe similar behavior in
> similar uses of 8 $. y).
> 
> I'm reporting this on the beta forum, but it's an issue in J903 (and,
> probably, earlier versions of J).
> 
> FYI,
> 
> -- 
> Raul
> ----------------------------------------------------------------------
> 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