Proposed changed to ⍳⍬
Posted: 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.)
)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.)