Catenating empty arrays

For users of dfns, both novice and expert

Catenating empty arrays

Postby Andrew Seary on Thu Oct 09, 2014 10:20 pm

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

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
This makes sense: catenating an empty vector to a results in no change to a.
IBM APL2, NARS2000, APL+Win:
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

Postby JohnS|Dyalog on Fri Oct 10, 2014 9:06 am

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 :-)
User avatar
Posts: 170
Joined: Wed Sep 10, 2008 10:01 am

Return to Functional Programming

Who is online

Users browsing this forum: No registered users and 1 guest