APL2 Code in Dyalog APL not working
5 posts
• Page 1 of 1
APL2 Code in Dyalog APL not working
This code gives desired results in IBM APL2 on Mainframes, but LENGTH
ERROR in Dyalog APL 12.1
APL2 Code:
The result of above statement in APL2 is 23 rows and 2 column matrix
of spaces.
My ultimate objective is to get result as no of columns of right hand
argument and no of rows of left argument. I mean 23 rows and 2 column
matrix of space.
I tried with below logic, but I am getting 0's as result instead
spaces, only when my left argument is an array of numeric 1. If its
is 0, then it gives LENGTH ERROR
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
Can someone please help me in resolving this?
ERROR in Dyalog APL 12.1
APL2 Code:
X←23 3 ⍴' ' (23 ROWS 3 COLUMS OF SPACES MATRIX)
(~∧/X∊' ?'⍀(1 2 ⍴'0'))
The result of above statement in APL2 is 23 rows and 2 column matrix
of spaces.
My ultimate objective is to get result as no of columns of right hand
argument and no of rows of left argument. I mean 23 rows and 2 column
matrix of space.
I tried with below logic, but I am getting 0's as result instead
spaces, only when my left argument is an array of numeric 1. If its
is 0, then it gives LENGTH ERROR
(y⍀((⍴y),2)⍴'0')00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
Can someone please help me in resolving this?
- anilkasat
- Posts: 6
- Joined: Tue Dec 13, 2011 8:23 am
Re: APL2 Code in Dyalog APL not working
I think you have a missing pair of parentheses in your first example, but I do agree that there may be a problem in that:
but
I will investigate and get back to you. Meanwhile, I think you can work around the problem by defining:
1 1 1\'X'
XXX
but
1 1 1⍀1 2⍴'X'
LENGTH ERROR
I will investigate and get back to you. Meanwhile, I think you can work around the problem by defining:
apl2expandrows←{⍺⍀((+/⍺),¯1↑⍴⍵)⍴⍵}
1 1 1 apl2expandrows 1 2⍴'X'
XX
XX
XX
1 0 1 apl2expandrows 1 2⍴'X'
XX
XX
-
Morten|Dyalog - Posts: 458
- Joined: Tue Sep 09, 2008 3:52 pm
Re: APL2 Code in Dyalog APL not working
Slightly more generally applicable:
For instance APL*PLUS used to allow inner product with a right argument having first dimension of 1 whatever else the shapes were. The data were effectively replicated to the trailing dimension of the left argument without taking up additional workspace.
It appears that APL2 also allows this though I suspect there are many other places where this could be done but isn't.
I doubt if any interpreter permits:
Personally I think it's better without.
I suspect the rank operator is the probably best way to do any of these.
apl2expandrows←{⍺⍀(+/⍺)⌿⍵}Though I don't agree that it's a "problem" that can be fixed unless Dyalog want to go the whole way and permit "scalar" extension wherever there is a dimension of 1.
For instance APL*PLUS used to allow inner product with a right argument having first dimension of 1 whatever else the shapes were. The data were effectively replicated to the trailing dimension of the left argument without taking up additional workspace.
It appears that APL2 also allows this though I suspect there are many other places where this could be done but isn't.
I doubt if any interpreter permits:
(2 3⍴⍳4),,5Candidates would include
LENGTH ERROR
(2 3⍴⍳4),,5
∧
, ⍪ / ⌿ \ ⍀ ,[] ⍪[] /[] ⌿[] \[] ⍀[]I should see it as a mistake to do this in one or two places without a commitment to do it throughout.
Personally I think it's better without.
I suspect the rank operator is the probably best way to do any of these.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: APL2 Code in Dyalog APL not working
Thanks a lot Morten and Phil.
Both of your suggestions worked for me and resolved my issue.
Cheers..Anil
Both of your suggestions worked for me and resolved my issue.
Cheers..Anil
- anilkasat
- Posts: 6
- Joined: Tue Dec 13, 2011 8:23 am
Re: APL2 Code in Dyalog APL not working
Apologies for my "Slightly more generally applicable" claim for the above. "Differently applicable" would have been a better description. Morten's works in 2d for both the single and the multiple row cases. Mine works only for the single row case but extends into more than 2 dimensions.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
5 posts
• Page 1 of 1
Return to Migrating from other Systems
Who is online
Users browsing this forum: No registered users and 0 guests
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group