bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Index-of function with structured left-argument


From: Hans-Peter Sorge
Subject: Re: Index-of function with structured left-argument
Date: Wed, 15 Apr 2020 11:30:52 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0

Hi,

Your ⎕IO is 0
 
⎕IO←1

      Display (2 2 ⍴ 104 105 106 107) ⍳ (3 4 ⍴ 100+⍳100)
┏→━━━━━━━━━━━━━━━━━━━━━━┓
↓┏⊖┓   ┏⊖┓   ┏⊖┓   ┏→━━┓┃
┃┃0┃   ┃0┃   ┃0┃   ┃1 1┃┃
┃┗━┛   ┗━┛   ┗━┛   ┗━━━┛┃
┃┏→━━┓ ┏→━━┓ ┏→━━┓ ┏⊖┓  ┃
┃┃1 2┃ ┃2 1┃ ┃2 2┃ ┃0┃  ┃
┃┗━━━┛ ┗━━━┛ ┗━━━┛ ┗━┛  ┃
┃┏⊖┓   ┏⊖┓   ┏⊖┓   ┏⊖┓  ┃
┃┃0┃   ┃0┃   ┃0┃   ┃0┃  ┃
┃┗━┛   ┗━┛   ┗━┛   ┗━┛  ┃
┗∊━━━━━━━━━━━━━━━━━━━━━━┛
⍝ this is the shape of the right argument and their indexes within the left argument.


      (2 2 ⍴ 104 105 106 107)  (3 4 ⍴ 100+⍳12)
 104 105   101 102 103 104
 106 107   105 106 107 108
           109 110 111 112

furthermore:
     104 105 106 107 ⍳  3 4 ⍴ 100+⍳12
5 5 5 1
2 3 4 5
5 5 5 5

so may be

(2 2 ⍴ 104 105 106 107) ⍳ (3 4 ⍴ 100+⍳100)

should be

┏→━━━━━━━━━━━━━━━━━━━━━━┓
↓┏→━━┓ ┏→━━┓ ┏→━━┓ ┏→━━┓┃
┃┃3 3┃ ┃3 3┃ ┃3 3┃ ┃1 1┃┃
┃┗━━━┛ ┗━━━┛ ┗━━━┛ ┗━━━┛┃
┃┏→━━┓ ┏→━━┓ ┏→━━┓ ┏→━━┓┃
┃┃1 2┃ ┃2 1┃ ┃2 2┃ ┃3 3┃┃
┃┗━━━┛ ┗━━━┛ ┗━━━┛ ┗━━━┛┃
┃┏→━━┓ ┏→━━┓ ┏→━━┓ ┏→━━┓┃
┃┃3 3┃ ┃3 3┃ ┃3 3┃ ┃3 3┃┃
┃┗━━━┛ ┗━━━┛ ┗━━━┛ ┗━━━┛┃
┗∊━━━━━━━━━━━━━━━━━━━━━━┛

Regards
Hans-Peter

Am 14.04.20 um 11:30 schrieb Jay Foad:
Just from staring at the result, it looks like the result of ⍺⍳⍵ has the same shape as ⍵, and for each item of ⍵ it tells you either the coordinates where it was found in ⍺, or ⍬ if it was not found. (Dunno what it does if ⍺ is a scalar, where ⍬ would be a valid coordinate.)

N.B. in Dyalog APL dyadic iota has been extended to high rank arrays in a completely different way: https://help.dyalog.com/17.1/#Language/Primitive%20Functions/Index%20Of.htm

Jay.

On Tue, 14 Apr 2020 at 09:15, Elias Mårtenson <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]