Indices: Difference between revisions

Jump to navigation Jump to search
No change in size ,  16:37, 15 November 2019
m
no edit summary
Miraheze>Adám Brudzewsky
No edit summary
Miraheze>Marshall
mNo edit summary
Line 1: Line 1:
:''This page describes a primitive whose result is a list of indices. See [[Index]] for the page on indices themselves. See [[Index of]] for the index generator.''
:''This page describes a primitive whose result is a list of indices. See [[Index]] for the page on indices themselves. See [[Index of]] for the index generator.''


{{Built-in|Indices|⍸}} or '''Where''', is a [[monadic]] [[primitive function]] which returns the [[Index|indices]] of all ones in a [[boolean]] array. More generally, Indices accepts an array of non-negative integers and copies each index the corresponding number of times.
{{Built-in|Indices|⍸}} or '''Where''', is a [[monadic]] [[primitive function]] which returns the [[Index|indices]] of all ones in a [[Boolean]] array. More generally, Indices accepts an array of non-negative integers and copies each index the corresponding number of times.


Indices was introduced in [[J]] as <source lang=j inline>I.</source> and is present in [[K]] as <source lang=k inline>&</source>.
Indices was introduced in [[J]] as <source lang=j inline>I.</source> and is present in [[K]] as <source lang=k inline>&</source>.
Line 7: Line 7:
== Examples ==
== Examples ==


In all implementations, Indices gives the indices of ones in a boolean [[vector]].
In all implementations, Indices gives the indices of ones in a Boolean [[vector]].
<source lang=apl>
<source lang=apl>
       ⍸ 0 0 1 0 0 0 1 0
       ⍸ 0 0 1 0 0 0 1 0
Line 42: Line 42:
{{Works in|[[Dyalog APL]], [[dzaima/APL]], [[NARS2000]], [[ngn/apl]]}}
{{Works in|[[Dyalog APL]], [[dzaima/APL]], [[NARS2000]], [[ngn/apl]]}}


The argument is restricted to be an array of non-negative integers, or, in [[Dyalog APL]], booleans.
The argument is restricted to be an array of non-negative integers, or, in [[Dyalog APL]], Booleans.


Because Indices returns indices (like [[Iota]]), it is subject to [[index origin]].
Because Indices returns indices (like [[Iota]]), it is subject to [[index origin]].
Anonymous user

Navigation menu