Proposed changed to ⍳⍬

General APL language issues

Proposed changed to ⍳⍬

Postby JohnS|Dyalog on Thu Apr 22, 2010 11:55 am

We're proposing to fix what might qualify as the longest standing bug in Dyalog. Currently, ⍳⍬ returns ⎕io; it should return ⊂⍬. To convince you that this is correct, look at the following sequence:

      )copy dfns.dws
...
      disp ⍳¨ ⍳¨ 3 2 1 0             ⍝ current behaviour
┌→──────────────────┬─────────┬─┬─┐
│┌→────┬─────┬─────┐│         │ │ │
│⍒1 1 1│1 1 2│1 1 3││┌→──┬───┐│ │ │
│├~───→┼~───→┼~───→┤│↓1 1│1 2││1│1│
││1 2 1│1 2 2│1 2 3││└~─→┴~─→┘│ │ │
│└~───→┴~───→┴~───→┘⍒         ↓ │ │
└──────────────────→┴────────→┴→┴─┘

      disp ⍳¨ ⍳¨ 3 2 1 0             ⍝ proposed behaviour
┌→──────────────────┬─────────┬─┬───┐
│┌→────┬─────┬─────┐│         │ │   │
│⍒1 1 1│1 1 2│1 1 3││┌→──┬───┐│ │┌─┐│
│├~───→┼~───→┼~───→┤│↓1 1│1 2││1││0││
││1 2 1│1 2 2│1 2 3││└~─→┴~─→┘│ │└⊖┘│
│└~───→┴~───→┴~───→┘⍒         ↓ │   │
└──────────────────→┴────────→┴→┴───┘

Notice how the sequences differ in the last item.

The correction would mean that:
      ⍵≡⍵[⍳⍴⍵]       ⍝ for all, including scalar, ⍵.
and that:
      (nelts¨ ⍳⍵) ∧.= nelts ⍵    ⍝ where: nelts←{⎕io⊃⍴,⍵}

If this change would cause you a problem, now would be a good time to mention it.

John.

(muse: From a consistency point of view, there's an argument for distinguishing ⍳3 from ⍳,3. This would enclose the penultimate item in the above sequence. But we can't to this because it would [a] break the APL standard, and [b] break everyone's code.)
JohnS|Dyalog
 

Re: Proposed changed to ⍳⍬

Postby PMH on Fri Apr 23, 2010 7:23 am

This should remain valid anyway:

Code: Select all
      {⊃⍴⍴⍳⍵}¨0 1 2 3 4 5⍴¨0
0 1 2 3 4 5
PMH
 
Posts: 7
Joined: Fri Nov 27, 2009 8:48 am

Re: Proposed changed to ⍳⍬

Postby JohnS|Dyalog on Fri Apr 23, 2010 5:25 pm

Yes, this will still be the case. With the fix:

Dyalog APL/W Version 13.0.5135
Serial No : 000000
Unicode Edition
DEBUG Build
Fri Apr 23 18:21:47 2010
clear ws

      {⊃⍴⍴⍳⍵}¨0 1 2 3 4 5⍴¨0
0 1 2 3 4 5
JohnS|Dyalog
 


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest