From bed78fe6147cb7921b7367960d406d28d37cb019 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 7 Jun 2022 22:16:01 -0400 Subject: The editing is going to end at some point isn't it? --- docs/doc/select.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'docs/doc/select.html') diff --git a/docs/doc/select.html b/docs/doc/select.html index aaa36cc3..566f6484 100644 --- a/docs/doc/select.html +++ b/docs/doc/select.html @@ -51,7 +51,7 @@

The function Select (โŠ) reorganizes the array ๐•ฉ along one or more axes based on indices given by ๐•จ. The result has the same depth as ๐•ฉ, since its elements are always elements of ๐•ฉ. This means it differs from Pick (โŠ‘), which takes elements from ๐•ฉ but can arrange them in any nested structure, including returning an element directly.

The monadic form First Cell (โŠ) gets the major cell with index 0, so that โŠ๐•ฉ is identical to 0โŠ๐•ฉ.

Single selection

-

Each axis of a BQN array is numbered starting at zero. Major cells are arranged along the first axis; in accordance with the leading axis principle, Select returns a major cell of ๐•ฉ when ๐•จ is an atom.

+

The major cells of an array are arranged along the first axis and numbered starting at 0. For a natural number ๐•จ, Select returns the major cell of ๐•ฉ with index ๐•จ.

โ†—๏ธ
    2 โŠ "abcdef"  # An enclosed element
 โ”Œยท   
 ยท'c' 
@@ -66,7 +66,7 @@
     0 โŠ <5  # No first axis to select from
 Error: โŠ: ๐•ฉ cannot be a unit
 
-

As a major cell of ๐•ฉ, the result has rank one less than it and its shape is 1โ†“โ‰ข๐•ฉ. ๐•ฉ must have rank one or more.

+

As a major cell, the result has rank one less than ๐•ฉ and shape 1โ†“โ‰ข๐•ฉ. Of course ๐•ฉ must have at least one axis to select along, or there are no major cells and you'll get an error.

The index ๐•จ has to be an integer less than โ‰ ๐•ฉ. It can be negative, in which case it must be greater than or equal to -โ‰ ๐•ฉ. Negative indices select from the end of ๐•ฉ, in that ยฏ1 indicates the last major cell and -โ‰ ๐•ฉ indicates the first. If โ‰ ๐•ฉ is 0, then no index is valid.

โ†—๏ธ
    ยฏ2 โŠ "abcdef"
 โ”Œยท   
@@ -76,6 +76,7 @@
     0 โŠ ""
 Error: โŠ: Indexing out-of-bounds (๐•จโ‰ก0, 0โ‰กโ‰ ๐•ฉ)
 
+

First Cell

The monadic case First Cell (โŠ๐•ฉ) is identical to 0โŠ๐•ฉ. It has the same restrictions: ๐•ฉ must have rank 1 or more, and length 1 or more.

โ†—๏ธ
    โŠ "abc"
 โ”Œยท   
@@ -92,7 +93,7 @@
 Error: โŠ: Argument cannot be an atom
 

First-axis selection

-

If ๐•จ is an array of numbers (including any empty array), then each number indicates a major cell of ๐•ฉ. In the simplest case, a list of numbers gives a result with the same rank as ๐•ฉ but maybe not the same length.

+

If ๐•จ is an array of numbers (including any empty array), then each number indicates a major cell of ๐•ฉ. In the simplest case, a list of numbers gives a result with the same rank as ๐•ฉ but the length of ๐•จ.

โ†—๏ธ
    2โ€ฟ3โ€ฟ3โ€ฟ0โ€ฟ4โ€ฟ1 โŠ "OlZEt"
 "ZEEOtl"
 
@@ -183,4 +184,4 @@
 โŸจ 450 451 452 453 454 455 456 457 458 459 โŸฉ
 

If an element of ๐•จ has rank more than 1, it increases the rank of ๐•ฉ rather than decreasing it. The general rule is that in the result, one axis of ๐•ฉ is replaced by all the axes of the corresponding element of ๐•จ (trailing axes are unchanged). So the final shape โ‰ข๐•จโŠ๐•ฉ is (โˆพโ‰ขยจ๐•จ)โˆพ๐•จโ‰ โŠธโ†“โ‰ข๐•ฉ. But this shape doesn't affect the elements retrieved from ๐•ฉ. In all cases, using โฅŠยจ๐•จ for the left argument and then reshaping the result would yield the same value.

-

Selection only ever applies to leading axes of ๐•ฉ. However, you can skip some leading axes using ห˜ or โމ, to select on any contiguous set of axes. In particular, use the one-axis case ๐•จโŠธโŠโމ(-k) ๐•ฉ to select along axis k of ๐•ฉ.

+

Selection only ever applies to leading axes of ๐•ฉ. However, you can skip some leading axes using Rank modifiers ห˜ or โމ, to select on any contiguous set of axes. In particular, use the one-axis case ๐•จโŠธโŠโމ(-k) ๐•ฉ to select along axis k of ๐•ฉ.

-- cgit v1.2.3