From 8342ba5e9392811dbc0514a97e847a44a5b330a2 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 6 Jun 2022 21:29:06 -0400 Subject: When I wrote all these docs did I really understand I'd have to edit them? --- docs/doc/replicate.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/doc/replicate.html') diff --git a/docs/doc/replicate.html b/docs/doc/replicate.html index 31e63228..4387373b 100644 --- a/docs/doc/replicate.html +++ b/docs/doc/replicate.html @@ -88,7 +88,7 @@

The functions Indices and Replicate are used to copy or filter data. They might be described as transforming a run-length encoding into unencoded form. On the other hand, Indices might be described as giving a sparse representation of ๐•ฉ, which is smaller if ๐•ฉ mostly consists of zeros.

BQN doesn't have any of the various features used in APL to add fills to the result of Replicate, like negative numbers in ๐•จ or an Expand (\) primitive. An alternative to Expand is to use Replicate with structural Under (โŒพ) to insert values into an array of fills.

Replicate

-

Given a list of natural numbers ๐•จ, Replicate repeats each major cell in ๐•ฉ the corresponding number of times. That is, ๐•จ and ๐•ฉ must have the same length, and the result includes iโŠ‘๐•จ copies of each cell iโŠ๐•ฉ, in order.

+

Given a list of natural numbers ๐•จ, Replicate repeats each major cell in ๐•ฉ the corresponding number of times. That is, ๐•จ and ๐•ฉ must have the same length, and the result includes iโŠ‘๐•จ copies of each cell iโŠ๐•ฉ, in order.

โ†—๏ธ
    2โ€ฟ1โ€ฟ0โ€ฟ2 / "abcd"
 "aabdd"
 
@@ -124,7 +124,7 @@
 "fie"
 

Here โ‰คโŸœ'i' is a pervasive function, so there's no need to add ยจ. Similarly, to filter major cells of an array, Fnห˜โŠธ/ could be used, applying Fn to one major cell at a time.

-

A similar pattern applies to Replicate as well. The function below tests which input characters are double quotes, but by adding one it changes the result to 1 for each non-quote character and 2 for quotes (but source code and display also double quotes here, so the input string has only two "s and the output has four).

+

This idea extends to Replicate as well. The function below tests which input characters are double quotes, but by adding one it changes the result to 1 for each non-quote character and 2 for quotes (but source code and display also double quotes here, so the input string has only two "s and the output has four).

โ†—๏ธ
    {1+'"'=๐•ฉ}โŠธ/ "for ""escaping"" quotes"
 "for """"escaping"""" quotes"
 
@@ -173,7 +173,7 @@ 1

Indices

-

The monadic form of / is much simpler than the dyadic one, with no multidimensional case or mismatched argument ranks. ๐•ฉ must be a list of natural numbers, and /๐•ฉ is the list ๐•ฉ/โ†•โ‰ ๐•ฉ. Its elements are the indices for ๐•ฉ, with index i repeated iโŠ‘๐•ฉ times.

+

The monadic form of / is much simpler than the dyadic one, with no multidimensional case or mismatched argument ranks. ๐•ฉ has to be a list of natural numbers, and /๐•ฉ is the list ๐•ฉ/โ†•โ‰ ๐•ฉ. Its elements are the indices for ๐•ฉ, with index i repeated iโŠ‘๐•ฉ times.

โ†—๏ธ
    / 3โ€ฟ0โ€ฟ1โ€ฟ2
 โŸจ 0 0 0 2 3 3 โŸฉ
 
@@ -211,7 +211,7 @@ 8 2 โ”˜ -

This means the transitions can be grouped exactly in pairs, the beginning and end of each group. Reshape with a computed length โˆ˜โ€ฟ2 groups these pairs, and then a scan -หœ`ห˜ can be used to convert the start/end format to start/length if wanted.

+

This means the transitions can be grouped exactly in pairs, the beginning and end of each group. Reshape with a computed length โˆ˜โ€ฟ2 groups these pairs, and then a scan -หœ`ห˜ can be used to convert the start/end format to start/length if wanted.

Inverse

The result of Indices /n is an ordered list of natural numbers, where the number i appears iโŠ‘n times. Given an ordered list of natural numbers k, the inverse of indices returns a corresponding n: one where the value iโŠ‘n is the number of times i appears in k.

โ†—๏ธ
    / 3โ€ฟ2โ€ฟ1
-- 
cgit v1.2.3