bug-apl
[Top][All Lists]

## Re: Reassignment of a nested array element

 From: Dr . Jürgen Sauermann Subject: Re: Reassignment of a nested array element Date: Wed, 8 Mar 2023 17:44:30 +0100 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

Hi,

I fixed a discrepancy between (3⊃V)← and
(1/3⊃V)←. SVN 1657.
We know have:

V←1 'bc' (3 3⍴⍳9) ◊ 8 ⎕CR V
┌→─────────────┐
│1 ┌→─┐ ┌→────┐│
│  │bc│ ↓1 2 3││
│  └──┘ │4 5 6││
│       │7 8 9││
│       └─────┘│
└ϵ─────────────┘
(3⊃V)←1           ◊ 8 ⎕CR V
┌→───────┐
│1 ┌→─┐ 1│
│  │bc│  │
│  └──┘  │
└ϵ───────┘
(1/3⊃V)←1         ◊ 8 ⎕CR V
┌→───────┐
│1 ┌→─┐ 1│
│  │bc│  │
│  └──┘  │
└ϵ───────┘

However, I don't quite get why, as suggested below, the results of

(3⊃V)← and of (1/3⊃V) should differ?

For me 1/X is the same as X (except for a length 1 axis added by 1/ when X is
scalar) and therefore
(3⊃V)←1 and (1/3⊃V)←1 should IMHO yield the same.

Best Regards,
Jürgen

On 3/6/23 9:16 PM, Hans-Peter Sorge wrote:
Hello Jürgen,

I agree with your case 1/2  Statement.

The examples I was showing is actually "off by 1".

I was referring to
(1/3⊃V)←1

having
a←1
b←'ABC'
c←3 3⍴⍳9
V←a b c
(3⊃V)
1 2 3 SVN 1657
4 5 6
7 8 9
As expected with case 1:
(3⊃V)←1

V
1 ABC 1

V←a b c
Not expected:
(1/3⊃V)←1

V
1 ABC 1

Expected:
(1/3⊃V)←1
V
1 ABC   1 1 1
1 1 1

1 1 1

as with

(1/c)←1
c
1 1 1
1 1 1
1 1 1

And that's Dyalog too.

Best Regards
Hans-Peter

Am 06.03.23 um 16:10 schrieb Dr. Jürgen Sauermann:
Gentlemen,

thanks for the discussion, fixed in SVN 1655.

Hans-Peter, I am sorry that this change creates an incompatibility in your code.

V←0 0 0
◊   V←1 ◊ V   ∩ case 1.
1

V←0 0 0  ◊   V[]←1 ◊ V   ⍝ case 2.
1 1 1

This applies to GNU APL, APL2, and Dyalog. The question is then if (A⊃V) in
(A⊃B)←X should behave like case 1 or like case 2 above. The case (A⊃B)←X
with nested (A⊃B)is described neither in the "IBM APL2 Language Reference"
nor in the "ISO 13751" standard, leaving some room for interpretation.

However, both APL2 and Dyalog agree on case 1 and therefore I changed
GNU APL to behave the same.

Best Regards,
Jürgen

On 3/4/23 8:25 PM, Hans-Peter Sorge wrote:
Hi,

Works as expected

⊃'Sue' 'Maria' 'Annalisa'
is an array 3 by 8.

⊂⊃'Susan' 'Mary' 'Annalisa'
is an element (⊂) of a 3 by 8  array (⊃'Susan' 'Mary' 'Annalisa' ).

Finally each element in  ⊃'Sue' 'Maria' 'Annalisa' gets assigned an array of  ⊃'Susan' 'Mary' 'Annalisa'

Greetings
Hans-Peter

Am 04.03.23 um 16:53 schrieb Mr. Sunday:
Hi,

I have an issue with reassigning an element of a nested array.  Here is an example.

14535:15a:~% apl --version
BUILDTAG:
---------
Project:        GNU APL
Version / SVN:  1.8 / SVN: 1651M
Build Date:     2023-03-02 00:25:07 UTC
Build OS:       Darwin 21.6.0 x86_64
config.status:  default ./configure options
Archive SVN:    1621

var←0 0 0 ⋄ (1⊃var)←5 4 ⋄ (2⊃var)←3 4⍴⍳12 ⋄ (3⊃var)←⊃'Sue' 'Maria' 'Annalisa' ⋄ var ⋄ (3⊃var)←⊂⊃'Susan' 'Mary' 'Annalisa' ⋄ var
┌→────────────────────────────┐
│┌→──┐ ┌→─────────┐ ┌→───────┐│
││5 4│ ↓1  2  3  4│ ↓Sue     ││
│└───┘ │5  6  7  8│ │Maria   ││
│      │9 10 11 12│ │Annalisa││
│      └──────────┘ └────────┘│
└ϵ────────────────────────────┘
┌→───────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│┌→──┐ ┌→─────────┐ ┌→──────────────────────────────────────────────────────────────────────────────────────┐│
││5 4│ ↓1  2  3  4│ ↓┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐││
│└───┘ │5  6  7  8│ │↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │││
│      │9 10 11 12│ ││Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │││
│      └──────────┘ ││Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│││
│                   │└────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘││
│                   │                                                                                       ││
│                   │┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐││
│                   │↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │││
│                   ││Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │││
│                   ││Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│││
│                   │└────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘││
│                   │                                                                                       ││
│                   │┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐ ┌→───────┐││
│                   │↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │ ↓Susan   │││
│                   ││Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │ │Mary    │││
│                   ││Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│ │Annalisa│││
│                   │└────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘││
│                   └ϵ──────────────────────────────────────────────────────────────────────────────────────┘│
└ϵϵ──────────────────────────────────────────────────────────────────────────────────────────────────────────┘

-- Everyday is Sunday.