Issue with ⍎ that worked fine in APLWIN and APLX

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...

Issue with ⍎ that worked fine in APLWIN and APLX

Postby lancepawl on Tue Nov 21, 2017 2:10 pm

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
lancepawl
 
Posts: 10
Joined: Tue Sep 05, 2017 1:43 pm

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

Postby Phil Last on Tue Nov 21, 2017 9:48 pm

Yes. Or you could change "1↑⍴" to be "⍬⍴" so that you don't get a matrix to begin with.
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

Postby Roger|Dyalog on Wed Nov 22, 2017 4:30 pm

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.
Roger|Dyalog
 
Posts: 238
Joined: Thu Jul 28, 2011 10:53 am


Return to New to Dyalog?

Who is online

Users browsing this forum: No registered users and 1 guest