Page 1 of 1

Issue with ⍎ that worked fine in APLWIN and APLX

Posted: Tue Nov 21, 2017 2:10 pm
by lancepawl
Hello,
I'm hoping someone has an idea about this. I have a simple piece of code that ran fine in WINAPL and APLX, but doesn't in Dyalog. The code extracts date information, (yyyymmdd, e.g., 20170910), from a character matrix and converts it to numeric, but I get a rank error in Dyalog. The code is: ⍎STATS[(1↑⍴STATS);cDATE]. The 1↑⍴STATS is going to give me the last row of the table, and cDATE is simply the columns 1 2 3 4 5 6 7 8, so I would get the latest date in character format, such as 20170910, and then convert this to a number, but this fails with a rank error.

I did find that the error is because the shape of STATS[(1↑⍴STATS);cDATE] evaluates to 1 8 and Dyalog doesn't like this. However, it also evaluated to 1 8 in APLWIN and APLX, but I did not get this rank error. Is there a setting in Dyalog to get around this error or am I going to have to resolve the error adding the ravel operator like this: ⍎,STATS[(1↑⍴STATS);cDATE] ?

Thanks & Regards,

Lance

Re: Issue with ⍎ that worked fine in APLWIN and APLX

Posted: Tue Nov 21, 2017 9:48 pm
by Phil Last
Yes. Or you could change "1↑⍴" to be "⍬⍴" so that you don't get a matrix to begin with.

Re: Issue with ⍎ that worked fine in APLWIN and APLX

Posted: Wed Nov 22, 2017 4:30 pm
by Roger|Dyalog
Note that ISO/IEC 13751:2001(E), the ISO standard for extended APL, had this to say about ⍎B (page 135):

If the rank of B is greater-than one, signal rank-error.

In addition to Phil's suggestion, you can also replace (1↑⍴STATS) by ≢STATS.