Catenating empty arrays
2 posts
• Page 1 of 1
Catenating empty arrays
Put here to catch John Schole's attention.
I really enjoyed the latest video on depth-first search!
To better understand it, I translated into Tradfns with []ML = 2.
I also put the Tradfns into IBM APL2 for Windows and the Dfns into
NARS2000-32.
Howvever, the latter two (and APL+Win) treat catenation of empty
arrays differently from Dyalog (!) and so the initialization in ACCM
returns the wrong empty array. To illustrate I will use symbols, mainly
since Preview makes the DISPLAY results messy-looking and I don't see all the APL symbols.
For QUEENS 2, with initial inputs to ACCM:
Set a={enclose}[2]0 2{rho}0
Set w=0{rho}{enclose}{iota}0
Dylaog:
a,w
a
This makes sense: catenating an empty vector to a results in no change to a.
IBM APL2, NARS2000, APL+Win:
a,w
w
This does not make as much sense. Maybe has something to do with identity element
of ravel (which Dyalog does not have?).
The fix is easy: reverse the inputs to ACCM, then reverse the output (needed for the non-empty cases).
But why this difference?
I really enjoyed the latest video on depth-first search!
To better understand it, I translated into Tradfns with []ML = 2.
I also put the Tradfns into IBM APL2 for Windows and the Dfns into
NARS2000-32.
Howvever, the latter two (and APL+Win) treat catenation of empty
arrays differently from Dyalog (!) and so the initialization in ACCM
returns the wrong empty array. To illustrate I will use symbols, mainly
since Preview makes the DISPLAY results messy-looking and I don't see all the APL symbols.
For QUEENS 2, with initial inputs to ACCM:
Set a={enclose}[2]0 2{rho}0
Set w=0{rho}{enclose}{iota}0
Dylaog:
a,w
a
This makes sense: catenating an empty vector to a results in no change to a.
IBM APL2, NARS2000, APL+Win:
a,w
w
This does not make as much sense. Maybe has something to do with identity element
of ravel (which Dyalog does not have?).
The fix is easy: reverse the inputs to ACCM, then reverse the output (needed for the non-empty cases).
But why this difference?
- Andrew Seary
- Posts: 1
- Joined: Wed Sep 24, 2014 11:50 pm
Re: Catenating empty arrays
Hi Andrew,
Dyalog used to have an inconsistent approach to the catenation of empty arrays. This was rationalised in Version 12 (issue number 3225). We judged returning the left null to be preferable and The Extended APL Standard for Join Along an Axis appears to agree: If B2 is empty, return (...)⍴A2, where A2 is ⍺ and B2 is ⍵.
So now:
Thanks for your kind words re DFS video :-)
John.
Dyalog used to have an inconsistent approach to the catenation of empty arrays. This was rationalised in Version 12 (issue number 3225). We judged returning the left null to be preferable and The Extended APL Standard for Join Along an Axis appears to agree: If B2 is empty, return (...)⍴A2, where A2 is ⍺ and B2 is ⍵.
So now:
⍬≡''
0
⍬≡⍬,''
1
''≡'',⍬
1
Thanks for your kind words re DFS video :-)
John.
- JohnS|Dyalog
2 posts
• Page 1 of 1
Return to Functional Programming
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group