Indices: Difference between revisions

Jump to navigation Jump to search
1,012 bytes added ,  19:56, 4 August 2021
(→‎Documentation: BQN link)
Line 57: Line 57:


[[K]] takes advantage of this relationship by removing the primitive Replicate entirely: the glyph <code>&</code> is paired with [[Minimum]] instead. In K, Replicate is performed by using Where and then [[Bracket indexing|indexing]].
[[K]] takes advantage of this relationship by removing the primitive Replicate entirely: the glyph <code>&</code> is paired with [[Minimum]] instead. In K, Replicate is performed by using Where and then [[Bracket indexing|indexing]].
== Inverse ==
The [[inverse]] of Indices, <source lang=apl inline>⍸⍣¯1</source>, is the mapping from an ordered (multi-)set of indices to an array where each element is the count for its position. For a simple non-empty vector <source lang=apl inline>Y</source> without duplicates, the expression <source lang=apl inline>R←(⍸⍣¯1)Y</source> gives a Boolean vector <source lang=apl inline>R</source> with ones at the indices in <source lang=apl inline>Y</source>. This is equivalent to <source lang=apl inline>R←(1@Y)0⍴⍨⌈/Y</source> which is useful in conversion between [[partition representations]].
It should be noted that the inverse is not unique because <source lang=apl inline>(⍸Y) ≡ (⍸Z)</source> if <source lang=apl inline>Y</source> and <source lang=apl inline>Z</source> differ only by the number of trailing zeros. <source lang=apl inline>⍸⍣¯1</source> does not add any trailing zeros, and it may be necessary to add those separately, for example using [[overtake]].


== History ==
== History ==

Navigation menu