Pick: Difference between revisions
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 (→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) | |||
┌───────┬───────┬───────┐ | ┌───────┬───────┬───────┐ | ||
│┌───┬─┐│┌───┬─┐│┌───┬─┐│ | │┌───┬─┐│┌───┬─┐│┌───┬─┐│ |
Revision as of 06:12, 9 June 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 shares the glyph ⊃
with First or Mix depending on the dialect.
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
External links
Documentation