bug-apl
[Top][All Lists]

Re: [Bug-apl] 8⎕CR on empty string array prints str ange result

 From: Elias Mårtenson Subject: Re: [Bug-apl] 8⎕CR on empty string array prints str ange result Date: Thu, 30 Jan 2014 16:22:55 +0800

OK, this was more complex than I understood. I'm still trying to grasp this stuff. :-)

In the document you linked to (thanks for that by the way!) they state the following:

Moreover, on certain implementations addition of empty arrays is not always commutative (e.g., L+R does not match R+L).

The implication here is that + should always be commutative. I noticed that it isn't on GNU APL. Is this a bug? Notice the difference between ⍬+f and f+⍬ below:

f← ('foo' 4)[⍬]
f
≡f
2
f+⍬
8⎕CR f+⍬
┌⊖┐
│0│
└─┘
8⎕CR ⍬+f
┌⊖────┐
│0 0 0│
└─────┘

Regards,
Elias

On 30 January 2014 12:53, Nick Lobachevsky wrote:
The difference is that a is an empty nested array and that b is an
empty simple array.  The depths would be different.  I tried this
example on Dyalog and ≡a is 2, one level of nesting, while ≡b is 1, a
simple vector.

Also see http://www.sudleyplace.com/APL/Prototype%20Functions.pdf

On 1/29/14, Elias Mårtenson <address@hidden> wrote:
> If I create an empty character array by selecting ⍬ from an array that
> contains a string and a number, the result becomes what seems to be an
> empty array with non-zero shape.
>
> The issue can best be explain by the following interaction. Note the
> strange output from 8⎕CR:
>
>       a←('foo' 9)[⍬]
>       b←''
>       a≡b
> 0
>       a
>       b
>       8⎕CR a
> ┌⊖──┐
> │   │
> └───┘
>       8⎕CR b
> ┌⊖┐
> │ │
> └─┘
>       ⍴a
> 0
>       ⍴b
> 0
>
>
> Regards,
> Elias
>