From 8b115bd20d7a91361a7fe87f293a8a53ff12406c Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 5 Jun 2022 17:19:14 -0400 Subject: Editing continues --- docs/doc/pick.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'docs/doc/pick.html') diff --git a/docs/doc/pick.html b/docs/doc/pick.html index 275b623a..060dcdc1 100644 --- a/docs/doc/pick.html +++ b/docs/doc/pick.html @@ -6,7 +6,7 @@

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.

-

With no 𝕨, monadic βŠ‘π•© takes the first element of 𝕩 in index order, with an error if 𝕩 is empty.

+

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:

@@ -23,7 +23,7 @@ Β―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. For convenience, a number is also allowed, but not an enclosed number (which could be confused with the nested case).

+

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 ⟩
 
@@ -40,14 +40,14 @@ 1β€ΏΒ―1 βŠ‘ a 'j' -

This applies even if 𝕩 is 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.

+

𝕩 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 performs a slight generalization of Pick with a default left argument 0¨≒𝕩. For a non-empty array it returns the first element in index order.

+

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"
@@ -55,9 +55,10 @@
     βŠ‘ ↕4β€Ώ2β€Ώ5β€Ώ1
 ⟨ 0 0 0 0 ⟩
 
-

If 𝕩 is empty then First results in an error, like Pick.

-↗️
    βŠ‘ ""
+

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

+↗️
    βŠ‘ ""
 Error: βŠ‘: Argument cannot be empty
+
     βŠ‘ β‰’Ο€
 Error: βŠ‘: Argument cannot be empty
 
-- cgit v1.2.3