bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reassignment of a nested array element


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

Hi Hans-Peter,

in contrast, I am getting this (SVN 1658):


      V←'A' (1 2 3 4 5) (3 3⍴1)
      V
 A  1 2 3 4 5   1 1 1
                1 1 1
                1 1 1
      (1/3⊃V) ≡ 3⊃V
1
     
      (3⊃V)←1
      (1/3⊃V) ≡ 3⊃V
1


Best Regards,
Jürgen


On 3/12/23 7:02 PM, Hans-Peter Sorge wrote:
Hi Jürgen,

back from wintry Hahnenklee/Harz here are my thoughts.

In ref.:  "like a variable or like part of variable"
I always look at the intermediate data content which I consider to be
identical from "variable point of view" and "part of variable point of view".  

In following example that symmetry gets broken.
     V
A  1 2 3 4 5   1 1 1  
               1 1 1  
               1 1 1  

     (1/3⊃V) ≡ 3⊃V

1

     (3⊃V)←1
     (1/3⊃V) ≡ 3⊃V
0

The test case you attached 
(1/3⊃V)←3 2⍴'ABCdef'
does what I would expect and it looks like it is in "variable context'.

Would the result differ if the case would be handled in "part of variable context"?

Best Regards
Hans-Peter

Am 10.03.23 um 16:54 schrieb Dr. Jürgen Sauermann:
Gentlemen,

thanks for your patience. I believe that I have now found a
solution that may please both of you. Attached is my testcase
file, please have a look.

I still believe that left values using A⊃V or A/B are ambiguous
as to whether their result shall be treated like a variable or like
part of variable (see my previous comment on V← vs. V[]←).

The fact that other APL interpreters decide that in one way or
the other seems not really satisfactory but somewhat arbitrary.
I would therefore propose to avoid such constructs for the sake
of portability.

Best Regards,
Jürgen


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

thank you for considering it.

Your work is admirable.

Best Regards
Hans-Peter

Am 09.03.23 um 17:49 schrieb Dr. Jürgen Sauermann:
Hi Hans-Peter,

you are probably right. This one looks rather tricky, therefore
I may need some time. But I am working on it.

Best Regards,
Jürgen


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

sorry that I'm so insistent

in
APL2 Programming: Language Reference
it is stated:

Selective Specification: Compress can be used for selective specification:
M
3 2ρι6
M
1 2
3 4
5 6
(1 0/M)
'ABC'
M
A 2
B 4
C 6


Using our example V
     V←1 'bc' M         
     V
1 bc   1 2  
       3 4  
       5 6 
The selective specification
     (1 0/3⊃V)←'ABC'
     V
1 bc ABC  
does not yield the same content for  3⊃V as for modified M.


Best Regards
Hans-Peter


Am 08.03.23 um 17:44 schrieb Dr. Jürgen Sauermann:
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.
Please restore compatibility:-)

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.

My thinking for the old solution was this:

   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.












reply via email to

[Prev in Thread] Current Thread [Next in Thread]