Difference between revisions of "Select"
(Created page with "{{BuiltinSelect⊇}} (jokingly referred to as ''Sane Indexing'') is a primitive function that allows selecting multiple major cells using indices of the cells. It i...") 
(No difference)

Latest revision as of 14:50, 12 February 2020
⊇

Select (⊇
) (jokingly referred to as Sane Indexing) is a primitive function that allows selecting multiple major cells using indices of the cells. It is equivalent to ⌷⍨∘⊂⍨
and ⌷⍤0 ∞
, only providing a neater notation for such a fundamental concept. It was introduced in Extended Dyalog APL, and then adopted into dzaima/APL.
Common usage
Select is commonly used to reorder the major cells of an array. For example, the following shuffles any array into random order:
Shuffle←?⍨∘≢⊇⊢
Shuffle 'abcdef'
fbdcea
Without Select, one would have to write Shuffle←⊢⌷⍨∘⊂?⍨∘≢
.
In a case where the left argument is a permutation vector for the right argument, the functionality can rightfully be called Permute.
Select especially cleans up expressions for reordering. An ascending sort can be represented as ⍋⊇⊢
and "sort by" can be written as ⊇⍨∘⍋
:
'abcde' ⊇⍨∘⍋ 3 1 4 1 5
bdace
APL builtins [edit]  

Primitive functions  
Scalar  
Monadic  Conjugate ∙ Not ∙ Roll ∙ Type  
Dyadic  Add ∙ Subtract ∙ Equal to (Xnor) ∙ Not Equal to (Xor)  
NonScalar  
Structural  Shape ∙ Reshape ∙ Tally ∙ Depth ∙ Ravel ∙ Reverse ∙ Raze ∙ Mix ∙ Cut (K) ∙ Pair  
Selection  Take ∙ Drop ∙ Unique ∙ Identity ∙ Select  
Selector  Interval Index  
Computational  Match ∙ Not Match ∙ Nub Sieve ∙ Format ∙ Execute  
Primitive operators  Each ∙ Reverse Compose  
Quad names  
Arrays  Index origin ∙ Migration level  
Functions  
Operators  
Other  Zilde ∙ High minus ∙ Function axis 