Catenating empty arrays

Don't hold back

Catenating empty arrays

PostPosted by seary » Sun Oct 12, 2014 1:46 pm

This topic came up on Dyalog Forum.

I wrote:
IBM APL2, NARS2000-32 and APL+Win treat catenation of empty
arrays differently from Dyalog.
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. Why the difference?

John Scholes replied
--------------------------------------------------------------------------------

Re: Catenating empty arrays

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
-----------------------------------------------------------------

Andrew Seary again, and sorry if not all the APL characters are visible.
The ⍬ is {zilde}.

Now:

Here's what IBM APL2, NARS2000 and APL+Win returns:

⍬≡''
0
⍬≡⍬,''
0
⍬≡'',⍬
1

That is, the RIGHT null is returned.
Would it be advisable for NARS2000 to conform with the Dyalog approach?
seary
 
Posts: 8
Joined: Tue Jan 27, 2009 10:38 pm

Re: Catenating empty arrays

PostPosted by forummaster » Mon Oct 20, 2014 8:53 am

seary wrote:This topic came up on Dyalog Forum.
[...]
Andrew Seary again, and sorry if not all the APL characters are visible.
The ⍬ is {zilde}.

Now:

Here's what IBM APL2, NARS2000 and APL+Win returns:

⍬≡''
0
⍬≡⍬,''
0
⍬≡'',⍬
1

That is, the RIGHT null is returned.
Would it be advisable for NARS2000 to conform with the Dyalog approach?

This topic was addressed several years ago in my "Prototype Functions" paper for APL2010 in Berlin: http://www.sudleyplace.com/APL/Prototyp ... ctions.pdf

A section from that paper reads:

"The One Coin Flip Case

There's really only one type of expression in APL1 where the answer isn't completely clear:
'',⍬ or its twin ⍬,'', or any equivalent higher rank expression. According to the rules of
catenation we know the answer must be a simple empty vector, we just don't know whether it's
numeric or character. Across all major APL implementations, the common rule (even when
empty nested arrays are considered) seems to be to choose the prototype of one of the arguments
as the prototype of the result. Alas, one vendor chooses the left, and all the others the right."

At this point no implementation is going to change as there's no value in changing.
forummaster
 
Posts: 567
Joined: Wed Jan 23, 2013 1:00 pm

Re: Catenating empty arrays

PostPosted by seary » Mon Nov 03, 2014 5:37 pm

It does make a difference.
I can send you a NARS WS with dfns that does a n-queens
dfs search, which I got from a John Scholes demo.
The function accm requires two reversals for the
solution to work in NARS (and APL2).
Compare with the original accm_Dyalog (included)
which requires no reversals since catenating two empty arrays
returns the LEFT array in Dyalog.
seary
 
Posts: 8
Joined: Tue Jan 27, 2009 10:38 pm

Re: Catenating empty arrays

PostPosted by forummaster » Thu Jan 26, 2017 4:53 am

seary wrote:It does make a difference.
I can send you a NARS WS with dfns that does a n-queens
dfs search, which I got from a John Scholes demo.
The function accm requires two reversals for the
solution to work in NARS (and APL2).
Compare with the original accm_Dyalog (included)
which requires no reversals since catenating two empty arrays
returns the LEFT array in Dyalog.

Sorry for the delay in responding. If you still have that ws, I'd love to see it.
forummaster
 
Posts: 567
Joined: Wed Jan 23, 2013 1:00 pm


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron