I suppose the reason is roughly this:
Some interpreter, including IBM APL2 and GNU APL, sometimes
allow 1-element vertors (lets call them quasi-scalars) in places
where strictly speaking scalars would be required.
Your partial results 0/x if some a=0 is always a vector while 1/x
for some other a-1 is always 1 1-element vector which is subject
to be being treated as a scalar instead.
When the the inner product f.g and the outer product ∘.g gets
a non-scalar result from g then it will enclose that result before
the f/ and disclose it again after the f/.
The final disclose will in your case see a mix of 0-element and
1-element vectors and will scalar-entend the 1-element
quasi-scalars to the common shape of all items which is,
in your example empty).
A different A reveals this:
(1⌈A≠0) +.Q B
6 6
6 6
6 6
Best Regards,
Jürgen
On 1/26/22 5:25 AM, Elias Mårtenson
wrote:
Consider the following code:
A←3 4⍴1 3 2 0 2 1 0 1 4 0 0 2
B←4 2⍴4 1 0 3 0 2 2 0
Q←{⍺/⍵}
(A≠0) +.Q B
My reading (and implementation) of the ISO spec suggests the output should be the following:
┏━━━┓
┃4 6┃
┃6 4┃
┃6 1┃
┗━━━┛
However, in GNU APL I get this:
┏→━━━━━━┓
↓┏⊖┓ ┏⊖┓┃
┃┃0┃ ┃0┃┃
┃┗━┛ ┗━┛┃
┃┏⊖┓ ┏⊖┓┃
┃┃0┃ ┃0┃┃
┃┗━┛ ┗━┛┃
┃┏⊖┓ ┏⊖┓┃
┃┃0┃ ┃0┃┃
┃┗━┛ ┗━┛┃
┗∊━━━━━━┛
Which one is correct?
Regards,Elias
