Mixed views on mix
8 posts
• Page 1 of 1
Mixed views on mix
A little startled to discover mix appears to have different definitions in Dyalog and APL+Win and APLX. (A long-standing divergence from APL2?)
The rule appears to be the width of the result is
Ugly migration issue, I fear. Thoughts on handling it?
V←'a' 'b' 'c' '' 'def'
⍴⊃5⍴V ⍝ APL+Win & APLX
5 3
⍴↑5⍴V ⍝ Dyalog
5 3
⍴⊃⍴V ⍝ APL+Win & APLX
4 0
⍴↑⍴V ⍝ Dyalog
4 1
The rule appears to be the width of the result is
⌈/≢¨⍵in Dyalog and
⌈/↑¨⍴¨⍵in APL+Win and APLX.
Ugly migration issue, I fear. Thoughts on handling it?
- sjt
- Posts: 21
- Joined: Fri Nov 05, 2010 6:26 am
Re: Mixed views on mix
Did you mean ⍴↑⍴¨V? (⍴↑⍴V would be ,1)
Since ⍴ will return an 0 or 1 element for each shouldn't the result be a 5x1?
Since ⍴ will return an 0 or 1 element for each shouldn't the result be a 5x1?
- DanB|Dyalog
Re: Mixed views on mix
Oops. No (typo) I mean:
⍴⊃5⍴V ⍝ APL+Win & APLX
5 3
⍴↑5⍴V ⍝ Dyalog
5 3
⍴⊃4⍴V ⍝ APL+Win & APLX
4 0
⍴↑4⍴V ⍝ Dyalog
4 1
- sjt
- Posts: 21
- Joined: Fri Nov 05, 2010 6:26 am
Re: Mixed views on mix
Stephen wrote:Ugly migration issue, I fear. Thoughts on handling it?
Migration To or From Dyalog?
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: Mixed views on mix
sjt wrote:Oops. No (typo) I mean:⍴⊃5⍴V ⍝ APL+Win & APLX
5 3
⍴↑5⍴V ⍝ Dyalog
5 3
⍴⊃4⍴V ⍝ APL+Win & APLX
4 0
⍴↑4⍴V ⍝ Dyalog
4 1
Yes, this is a long-standing difference between Dyalog and APL2. If you mix scalars and vectors the system has to find the maximum length of the vectors. APL2 ignores scalars when doing this; Dyalog treats them as vectors of length 1.
One point in favour of the "Dyalog way" is that it extends naturally to mixing items of any rank, by prefixing 1s to the shape of low-rank items to bring them all up to a common maximum rank. (And then bringing them all up to a common maximum shape along each axis as usual). This extension was implemented in Dyalog 14.0.
- Jay|Dyalog
Re: Mixed views on mix
Thanks to all for corrections and comments.
Any thoughts on how to deal with this difference when migrating to Dyalog?
Any thoughts on how to deal with this difference when migrating to Dyalog?
- sjt
- Posts: 21
- Joined: Fri Nov 05, 2010 6:26 am
Re: Mixed views on mix
If you really want it to go on doing that after migration then
OK for mix of vectors and scalars but length error for situation mentioned by Jay. Could be worked in.
di{↑(⌈/(⍴¨⍵)~⊂⍬)↑¨⍵}'⍬' '⍬' '' '123'
43--.
|⍬ |
|⍬ |
| |
|123|
'---'
di{↑(⌈/(⍴¨⍵)~⊂⍬)↑¨⍵}'⍬' '⍬' ''
30.
| |
| |
| |
'-'
di{↑(⌈/(⍴¨⍵)~⊂⍬)↑¨⍵}'⍬'
.-.
|⍬|
'-'
di{↑(⌈/(⍴¨⍵)~⊂⍬)↑¨⍵}''
0-.
| |
'-'
OK for mix of vectors and scalars but length error for situation mentioned by Jay. Could be worked in.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
8 posts
• Page 1 of 1
Return to Migrating from other Systems
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group