Pick: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Created page with "{{Built-in|Pick|⊃}} is a dyadic primitive function which performs deep indexing on a possibly nested array. Pick allows to extract a value through multiple l...")
 
m (Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com")
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Built-in|Pick|⊃}} is a [[dyadic]] [[primitive function]] which performs deep [[indexing]] on a possibly [[nested array]]. Pick allows to extract a value through multiple layers of nesting in a single function application. Pick shares the [[glyph]] <source lang=apl inline>⊃</source> with [[First]] or [[Mix]] depending on the dialect.
{{Built-in|Pick|⊃}} is a [[dyadic]] [[primitive function]] which performs deep [[indexing]] on a possibly [[nested array]]. Pick allows to extract a value through multiple layers of nesting in a single function application. Pick uses the [[Right Shoe]] glyph.


== Examples ==
== Examples ==
Line 6: Line 6:


<source lang=apl>
<source lang=apl>
       ⊢G←2 3⍴('ABC' 1)('DEF' 2)('GHI' 3)('JKL' 4)('MNO' 5)('PQR' 6)
       ⎕←G←2 3⍴('ABC' 1)('DEF' 2)('GHI' 3)('JKL' 4)('MNO' 5)('PQR' 6)
┌───────┬───────┬───────┐
┌───────┬───────┬───────┐
│┌───┬─┐│┌───┬─┐│┌───┬─┐│
│┌───┬─┐│┌───┬─┐│┌───┬─┐│
Line 25: Line 25:
K
K
</source>
</source>
== See also ==
* [[Index (function)]]
* [[Bracket indexing]]
* [[Select]]


== External links ==
== External links ==
Line 30: Line 35:
=== Documentation ===
=== Documentation ===


* [http://help.dyalog.com/latest/#Language/Primitive%20Functions/Pick.htm Dyalog]
* [https://help.dyalog.com/latest/#Language/Primitive%20Functions/Pick.htm Dyalog]
* [http://microapl.com/apl_help/ch_020_020_610.htm APLX]
* [http://microapl.com/apl_help/ch_020_020_610.htm APLX]


{{APL built-ins}}[[Category:Primitive functions]]
{{APL built-ins}}[[Category:Primitive functions]]

Revision as of 14:33, 14 July 2020

Pick () is a dyadic primitive function which performs deep indexing on a possibly nested array. Pick allows to extract a value through multiple layers of nesting in a single function application. Pick uses the Right Shoe glyph.

Examples

The left argument X must be a vector where each element of X specifies the multi-dimensional index at each layer of the right argument Y. The result of X⊃Y is the item of Y at the location specified by X.

      ⎕←G←2 3⍴('ABC' 1)('DEF' 2)('GHI' 3)('JKL' 4)('MNO' 5)('PQR' 6)
┌───────┬───────┬───────┐
│┌───┬─┐│┌───┬─┐│┌───┬─┐│
││ABC│1│││DEF│2│││GHI│3││
│└───┴─┘│└───┴─┘│└───┴─┘│
├───────┼───────┼───────┤
│┌───┬─┐│┌───┬─┐│┌───┬─┐│
││JKL│4│││MNO│5│││PQR│6││
│└───┴─┘│└───┴─┘│└───┴─┘│
└───────┴───────┴───────┘
      (⊂2 1)⊃G
┌───┬─┐
│JKL│4│
└───┴─┘
      ((2 1)1)⊃G
JKL
      ((2 1)1 2)⊃G
K

See also

External links

Documentation


APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)
Quad names Index originComparison toleranceMigration levelAtomic vector