Issue with ⍎ that worked fine in APLWIN and APLX

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...
Post Reply
lancepawl
Posts: 10
Joined: Tue Sep 05, 2017 1:43 pm

Issue with ⍎ that worked fine in APLWIN and APLX

Post 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
User avatar
Phil Last
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

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

Post by Phil Last »

Yes. Or you could change "1↑⍴" to be "⍬⍴" so that you don't get a matrix to begin with.
Roger|Dyalog
Posts: 238
Joined: Thu Jul 28, 2011 10:53 am

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

Post 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.
Post Reply