a strange difference Dyalog 12.1 vs 11

General APL language issues

a strange difference Dyalog 12.1 vs 11

Postby giangiquario on Mon Jan 25, 2010 3:29 pm

Dyalog 12.1 and Dyalog 11 return a different result.
I met this problem during tests of old funtions (built in Dyalog 10).


The following image shows an example of this difference.

differenzaDyalog121.JPG
differenzaDyalog121.JPG (28.8 KiB) Viewed 8865 times


I do not understand which behaviour is correct.
May be the opinions can be different.
User avatar
giangiquario
 
Posts: 46
Joined: Thu Nov 26, 2009 8:55 am
Location: Milano, Italia

Re: a strange difference Dyalog 12.1 vs 11

Postby Phil Last on Mon Jan 25, 2010 5:44 pm

Good question:
Broken down and in origin zero:
      ]display {⍵}w←0 3⍴(⍳4)0 0
┌→──────────────────────────────┐
⌽ ┌→──────┐ ┌→──────┐ ┌→──────┐ │
│ │0 0 0 0│ │0 0 0 0│ │0 0 0 0│ │
│ └~──────┘ └~──────┘ └~──────┘ │
└∊──────────────────────────────┘
      ]display {⍵}a←w[;0]
┌⊖──────────┐
│ ┌→──────┐ │
│ │0 0 0 0│ │
│ └~──────┘ │
└∊──────────┘
      ]display {⍵}b←⍬∘⍴¨0 1↓w
┌→──┐
⌽0 0│
└~──┘
      ]display a,b
┌→──────────────────────────────┐
⌽ ┌→──────┐ ┌→──────┐ ┌→──────┐ │
│ │0 0 0 0│ │0 0 0 0│ │0 0 0 0│ │
│ └~──────┘ └~──────┘ └~──────┘ │
└∊──────────────────────────────┘
So catenating a zero item nested vector and a zero row simple matrix now gives a zero row nested matrix. Interesting. The shape is correct so it's the depth that's changed.
There were problems with the types of the catenations of various pairs out of the three:

⍬, '' and (0⍴#)

which I understood to have been corrected such that the result takes its type from the left argument.

I guess this is a similar case.
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: a strange difference Dyalog 12.1 vs 11

Postby JohnS|Dyalog on Tue Jan 26, 2010 9:41 am

Phil is right: Catenation of a pair of null arrays produces a null result. The prototypical item of this result is drawn from one of the arguments.

Prior to V12, the choice of which argument, left or right, should supply this item was "interesting":

Code: Select all
    display ⍬,''         ⍝ prototypical item from left arg.
┌⊖┐
│0│
└~┘
    display '',⍬         ⍝ prototypical item from left arg.
┌⊖┐
│ │
└─┘
    display ⍬,0⍴⊂0 0     ⍝ prototypical item from left arg.
┌⊖┐
│0│
└~┘
    display (0⍴⊂0 0),⍬   ⍝ prototypical item from RIGHT arg V≤11
┌⊖┐
│0│
└~┘

From V12 onwards, this behaviour has been rationalised so that the prototypical item of a null catenate is always drawn from its left argument.

Code: Select all
    display '',⍬         ⍝ prototypical item from left arg.
┌⊖┐
│ │
└─┘
    display ⍬,''         ⍝ prototypical item from left arg.
┌⊖┐
│0│
└~┘
    display ⍬,0⍴⊂0 0     ⍝ prototypical item from left arg.
┌⊖┐
│0│
└~┘
    display (0⍴⊂0 0),⍬   ⍝ prototypical item from left arg V≥12
┌⊖──────┐
│ ┌→──┐ │
│ │0 0│ │
│ └~──┘ │
└∊──────┘

(Muse: this behaviour feels natural to me as long as we read APL from left to right)
JohnS|Dyalog
 


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest