On 11/30/2019 8:50 AM, iamjimfan@gmail.com wrote:
> Hi all,
>
> I believe this behaviour is buggy and would like to see if anyone can shed some light on it:
>
> I was trying to generate 6-out-of-49 combinations for my local lotto, using the captioned APL expression:
>
>
> ⍪{⍵?49}¨4⍴6
> 26 8 17 4 18 40
> 26 8 17 4 18 40
> 26 8 17 4 18 40
> 26 8 17 4 18 40
>
>
> My understanding is, {⍵?49} should be invoked 4 times to each of the 6 yielded by 4⍴6. Thus it should be highly unlikely that all 4 rows are the same.
>
> Even worse, I run the same expression again right under the output. And I get same numbers again:
>
>
> ⍪{⍵?49}¨4⍴6
> 26 8 17 4 18 40
> 26 8 17 4 18 40
> 26 8 17 4 18 40
> 26 8 17 4 18 40
>
>
>
> ⍪{⍵?49}¨4⍴6
> 26 8 17 4 18 40
> 26 8 17 4 18 40
> 26 8 17 4 18 40
> 26 8 17 4 18 40
>
>
> The implementation used is NARS2000 (Win64) version # 0.5.13.0
>
> What do you think?
>
> Jim
>
I'm not sure why all 4 results in the same invocation have the same
result, but I'm pretty sure the reason running the same expression again
produces the same results is because "Unlike user-defined functions, in
[anonymous functions and operators] all names to which an assignment is
made are automatically localized" (see
http://wiki.nars2000.org/index.php/Anonymous_Functions/Operators/Hyperators#Localization).
Even though you're not explicitly assigning ⎕RL, it's being implicitly
assigned as a side-effect of running ?. Here's a much simpler example:
⎕IO
1
{⎕IO←0}
⎕IO
1
As far as Dyalog, its documentation for dfns says "An expression whose
principal function is a simple or vector assignment, introduces a name
that is local to the dfn. The name is localised dynamically as the
assignment is executed." I don't know for Dyalog if that extends to
system variables too, particularly implicit assignment such as with ?
and ⎕RL.
|
|