|
From: | Dr . Jürgen Sauermann |
Subject: | Re: Index-of function with structured left-argument |
Date: | Tue, 14 Apr 2020 12:10:50 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
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, |
[Prev in Thread] | Current Thread | [Next in Thread] |