From 2afb23928e1984d475cc460e1672e8f6fa0e4dbe Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 11 Aug 2021 17:21:31 -0400 Subject: Allow clicking on header to get fragment link --- docs/doc/reshape.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'docs/doc/reshape.html') diff --git a/docs/doc/reshape.html b/docs/doc/reshape.html index 58b7dece..e9523103 100644 --- a/docs/doc/reshape.html +++ b/docs/doc/reshape.html @@ -4,7 +4,7 @@ BQN: Deshape and Reshape -

Deshape and Reshape

+

Deshape and Reshape

@@ -60,7 +60,7 @@

The glyph indicates BQN's facilities to reflow the data in an array, giving it a different shape. Its monadic form, Deshape, simply removes all shape information, returning a list of all the elements from the array in reading order. With a left argument, is called Reshape and is a more versatile tool for rearranging the data in an array into the desired shape.

Because of its dependence on the reading order of an array, Reshape is less fundamental than other array operations. Using Reshape in the central computations of a program can be a sign of imperfect usage of arrays. For example, it may be useful to use Reshape to create a constant array or repeat a sequence of values several times, but the same task might also be accomplished more simply with Table , or by taking advantage of leading axis agreement in arithmetic primitives.

-

Deshape

+

Deshape

The result of Deshape is a list containing the same elements as the argument.

↗️
     a  +⌜´ 100200, 3040, 567
 ┌─             
@@ -94,10 +94,10 @@
      2
 ⟨ 2 ⟩
 
-

Reshape

+

Reshape

While Deshape removes all shape information from its argument array, Reshape adds shape information back based on the left argument. Reshape ignores the shape of its original argument, treating it like a list of elements as though it were deshaped initially.

The left argument of Reshape gives the shape of the result, except that one entry can be left unspecified for BQN to fill in. We'll look at the cases where a full shape is given first.

-

Matching lengths

+

Matching lengths

If the number of elements implied by the given shape—that is, ×´𝕨—is equal to the number of elements in 𝕩, then 𝕩 is simply rearranged to match that shape. The element list is kept the same, so that the deshaped result matches the deshaped right argument.

↗️
    a
 ┌─             
@@ -133,7 +133,7 @@
   7 8 9 10 11 12 13  
                     ┘
 
-

Non-matching lengths

+

Non-matching lengths

If 𝕨 implies a smaller number of elements than are present initially, then only the initial elements of 𝕩 are used. Here the result stops at 237, three-quarters of the way through a, because at that point the result is filled up.

↗️
    33  a
 ┌─             
@@ -160,7 +160,7 @@ ERROR
     5  < "string"
 ⟨ "string" "string" "string" "string" "string" ⟩
 
-

Computed lengths

+

Computed lengths

What if you want to reshape an array into, say, rows of length 2, but don't want to write out the number of rows?

↗️
    2  "aAeEiIoOuU"
 ┌─    
-- 
cgit v1.2.3