bug-apl
[Top][All Lists]

## Re: Index-of function with structured left-argument

 From: Jay Foad Subject: Re: Index-of function with structured left-argument Date: Tue, 14 Apr 2020 10:30:19 +0100

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