Hi again,

just saw that this is documented in "info apl" section "3.17.2 Generalized dyadic ⍳".

Apparently your ⎕IO is 0 which makes it a bit mysterious. Otherwise:


      A←2 2 ⍴ 104 105 106 107
      B←3 4 ⍴ 100+⍳100
      A
104 105
106 107
      B
101 102 103 104
105 106 107 108
109 110 111 112

      4 ⎕CR A⍳B
┏→━━━━━━━━━━━━━━━━━━━━━━┓
↓┏⊖┓   ┏⊖┓   ┏⊖┓   ┏→━━┓┃
┃┃0┃   ┃0┃   ┃0┃   ┃1 1┃┃
┃┗━┛   ┗━┛   ┗━┛   ┗━━━┛┃
┃┏→━━┓ ┏→━━┓ ┏→━━┓ ┏⊖┓  ┃
┃┃1 2┃ ┃2 1┃ ┃2 2┃ ┃0┃  ┃
┃┗━━━┛ ┗━━━┛ ┗━━━┛ ┗━┛  ┃
┃┏⊖┓   ┏⊖┓   ┏⊖┓   ┏⊖┓  ┃
┃┃0┃   ┃0┃   ┃0┃   ┃0┃  ┃
┃┗━┛   ┗━┛   ┗━┛   ┗━┛  ┃
┗∊━━━━━━━━━━━━━━━━━━━━━━┛

Then:

- the result has the same shape as A since every element of A is being
searched in (the ravel of) B.

- The first three and the last five result elements are ⍬ because the
A items 
101 102 103 (first three) and 108 109 110 111 112
(the last five) were not found in B. Items not found get an index of ⍬
while found ones get the index of B where they (first) occurred in B.

Just like in the vector case. The only difference is ⍬ instead of ⎕IO+⍴B
for elements not in B. I simply considewred that to be more consistent
(and far easier to check) then other alternatives like
⎕IO+⍴B or ⎕IO+⍴,B
or
⎕IO+↑⍴B).

Best Regards,
Jürgen


On 4/14/20 11:39 AM, Dr. Jürgen Sauermann wrote:
Hi Elias,

my best guess is that this is a missing RANK ERROR somewhere.
I will look into it.

Best Regards,
Jürgen


On 4/14/20 10:15 AM, Elias Mårtenson wrote:
The ISO spec doesn't address what the index-of function should do when the left argument is not a scalar or a one-dimensional array.

GNU APL extends this, but I don't really understand in what way. How am I to interpret the output from this?

      (2 2 ⍴ 104 105 106 107) ⍳ (3 4 ⍴ 100+⍳100)
┏→━━━━━━━━━━━━━━━━━━━━━━┓
↓┏⊖┓   ┏⊖┓   ┏⊖┓   ┏⊖┓  ┃
┃┃0┃   ┃0┃   ┃0┃   ┃0┃  ┃
┃┗━┛   ┗━┛   ┗━┛   ┗━┛  ┃
┃┏→━━┓ ┏→━━┓ ┏→━━┓ ┏→━━┓┃
┃┃0 0┃ ┃0 1┃ ┃1 0┃ ┃1 1┃┃
┃┗━━━┛ ┗━━━┛ ┗━━━┛ ┗━━━┛┃
┃┏⊖┓   ┏⊖┓   ┏⊖┓   ┏⊖┓  ┃
┃┃0┃   ┃0┃   ┃0┃   ┃0┃  ┃
┃┗━┛   ┗━┛   ┗━┛   ┗━┛  ┃
┗∊━━━━━━━━━━━━━━━━━━━━━━┛

Regards,
Elias


Reply via email to