Indices: Difference between revisions

Jump to navigation Jump to search
848 bytes added ,  18:45, 11 December 2019
Line 51: Line 51:


Indices may be viewed as a way to convert between two ways of writing [[wikipedia:multiset|multiset]]s of array [[Index|indices]]. The argument uses a dense representation indicating for each index the number of times it appears, and the result uses a sparse representation which lists all the indices contained in the set.
Indices may be viewed as a way to convert between two ways of writing [[wikipedia:multiset|multiset]]s of array [[Index|indices]]. The argument uses a dense representation indicating for each index the number of times it appears, and the result uses a sparse representation which lists all the indices contained in the set.
== Relation with Replicate ==
Indices on a [[vector]] is closely related to [[Replicate]]: for vectors <source lang=apl inline>V</source> and <source lang=apl inline>W</source>, we have <source lang=apl inline>⍸V</source> {{←→}} <source lang=apl inline>V/⍳≢V</source> and <source lang=apl inline>V⌿X</source> {{←→}} <source lang=apl inline>X[⍸V]</source>. While Replicate performs a transformation on another array, Indices gives a representation of that transformation using [[Index|indices]]. The relationship between Indices and Replicate parallels that between [[Grade]] and [[Sort By]].
[[K]] takes advantage of this relationship by removing the primitive Replicate entirely: the glyph <source lang=k inline>&</source> is paired with [[Minimum]] instead. In K, Replicate is performed by using Where and then [[indexing]].


== History ==
== History ==

Navigation menu