Pick

Pick (βŠ‘) chooses elements from 𝕩 based on index lists from 𝕨. 𝕨 can be a plain list, or even one number if 𝕩 is a list, in order to get one element from 𝕩. It can also be an array of index lists, or have deeper array structure: each index list will be replaced with the element of 𝕩 at that index, effectively applying to 𝕨 at depth 1.

The one-argument form is called First, and βŠ‘π•© takes the first element of 𝕩 in index order, with an error if 𝕩 is empty.

While sometimes "scatter-point" indexing is necessary, using Pick to select multiple elements from 𝕩 is less array-oriented than Select (⊏), and probably slower. Consider rearranging your data so that you can select along axes instead of picking out elements.

One element

When the left argument is a number, Pick gets an element from a list:

↗️
    2 βŠ‘ 0β€Ώ1β€Ώ2β€Ώ3β€Ώ4
2
    2 βŠ‘ "abc"
'c'
    2 βŠ‘ ⟨@, 0β€Ώ1β€Ώ2β€Ώ3, "abc"⟩
"abc"

A negative number 𝕨 behaves like 𝕨+≠𝕩, so that Β―1 will select the last element, and -≠𝕩 the first. A number in 𝕨 must be an integer less than ≠𝕩 but not less than -≠𝕩.

↗️
    Β―2 βŠ‘ 0β€Ώ1β€Ώ2β€Ώ3β€Ώ4
3
    Β―2 βŠ‘ "abc"
'b'

Making 𝕩 a list is only a special case. In general 𝕨 can be a list of numbers whose length is 𝕩's rank. So when =𝕩 is 1, 𝕨 can be length-1 list. The case above where 𝕨 is a number is a simplification, but an enclosed number 𝕨 isn't allowed because it could be confused with the nested case described below.

↗️
    ⟨2,0⟩ βŠ‘ ↕4β€Ώ5
⟨ 2 0 ⟩

Above we see that picking from the result of Range gives the index. For something slightly more interesting, here's a character array:

↗️
    ⊒ a ← 'a' + β₯ŠβŸœ(↕×´) 4β€Ώ5
β”Œβ”€       
β•΅"abcde  
  fghij  
  klmno  
  pqrst" 
        β”˜
    2β€Ώ0 βŠ‘ a
'k'
    1β€ΏΒ―1 βŠ‘ a
'j'

𝕩 can even be a unit. By definition it has rank 0, so the only possible value for 𝕨 is the empty list. This extracts an enclosed element, and returns an atom unchangedβ€”the atom is promoted to an array by enclosing it, then the action of Pick undoes this. But there's rarely a reason to use this case, because the monadic form First accomplishes the same thing.

↗️
    ⟨⟩ βŠ‘ <'a'
'a'
    ⟨⟩ βŠ‘ 'a'
'a'

First

With no left argument, βŠ‘ is called First, and is the same as Pick with a default left argument 0¨≒𝕩. For a non-empty array it returns the first element in index order.

↗️
    βŠ‘ <'a'
'a'
    βŠ‘ "First"
'F'
    βŠ‘ ↕4β€Ώ2β€Ώ5β€Ώ1
⟨ 0 0 0 0 ⟩

And if 𝕩 is empty then First results in an error.

↗️
    βŠ‘ ""
Error: βŠ‘: Argument cannot be empty

    βŠ‘ β‰’Ο€
Error: βŠ‘: Argument cannot be empty

In APL it's common to get the last element of a list with an idiom that translates to βŠ‘βŒ½, or First-Reverse. In BQN the most straightforward way is to select with index Β―1 instead. I also sometimes use Fold with the Right identity function.

↗️
    βŠ‘βŒ½ "last"
't'
    Β―1βŠ‘ "last"
't'
    ⊒´ "last"
't'

Many elements

Pick also accepts a list of indices:

↗️
    a  # Defined above
β”Œβ”€       
β•΅"abcde  
  fghij  
  klmno  
  pqrst" 
        β”˜

    ⟨2β€Ώ0, 1β€ΏΒ―1, 3β€Ώ1, Β―1β€ΏΒ―1⟩ βŠ‘ a
"kjqt"

These indices have to be lists, since if they're numbers it just looks like 𝕨 is an index list for one element.

↗️
    ⟨2,1,0,Β―1⟩ βŠ‘ "abc"  # 𝕩 doesn't have rank 4!
Error: βŠ‘: Picking item at wrong rank (index 2β€Ώ1β€Ώ0β€ΏΒ―1 in array of shape ⟨3⟩)

    ⟨2,1,0,Β―1⟩ β₯ŠΒ¨βŠΈβŠ‘ "abc"
"cbac"

    ⟨2,1,0,¯1⟩ ⊏ "abc"  # Better way
"cbac"

It's much more general than just a list of indices though. As long as your indices are lists, you can arrange them in any array structure with arbitrary nesting.

↗️
    ⟨2β€Ώ0, ⟨⟨1β€ΏΒ―1, 3β€Ώ1⟩, Β―1β€ΏΒ―1⟩⟩ βŠ‘ a
⟨ 'k' ⟨ "jq" 't' ⟩ ⟩

    (⟨2β€Ώ0, 1β€ΏΒ―1βŸ©β‰βŸ¨3β€Ώ1, Β―1β€ΏΒ―1⟩) βŠ‘ a
β”Œβ”€    
β•΅"kj  
  qt" 
     β”˜

    (⟨2β€Ώ0, <1β€ΏΒ―1βŸ©β‰βŸ¨<3β€Ώ1, Β―1β€ΏΒ―1⟩) βŠ‘ a
β”Œβ”€             
β•΅ 'k'   β”ŒΒ·     
        Β·'j'   
            β”˜  
  β”ŒΒ·    't'    
  Β·'q'         
      β”˜        
              β”˜

This option is easily described using the Depth modifier. Pick applies to depth-1 components of the left argument and the entire right argument, which corresponds to a depth operand of 1β€Ώβˆž. The left argument components have to be lists of numbers, or Pick gives an error.

↗️
    (⟨2β€Ώ0, <1β€ΏΒ―1βŸ©β‰βŸ¨<3β€Ώ1, Β―1β€ΏΒ―1⟩) βŠ‘βš‡1β€Ώβˆž a
β”Œβ”€             
β•΅ 'k'   β”ŒΒ·     
        Β·'j'   
            β”˜  
  β”ŒΒ·    't'    
  Β·'q'         
      β”˜        
              β”˜

    ⟨⟨2,3⟩,1⟩ βŠ‘ a  # 1 isn't a valid index
Error: βŠ‘: 𝕨 contained list with mixed-type elements