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/replicate.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/doc/replicate.html') diff --git a/docs/doc/replicate.html b/docs/doc/replicate.html index 844b67c9..4e8aba5d 100644 --- a/docs/doc/replicate.html +++ b/docs/doc/replicate.html @@ -4,7 +4,7 @@ BQN: Indices and Replicate -

Indices and Replicate

+

Indices and Replicate

@@ -87,7 +87,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

+

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.

↗️
    2102 / "abcd"
 "aabdd"
@@ -128,7 +128,7 @@
 ↗️
    {1+'"'=𝕩}/ "for ""escaping"" quotes"
 "for """"escaping"""" quotes"
 
-

Compound Replicate

+

Compound Replicate

If 𝕨 has depth two, then its elements give the amounts to copy along each leading axis of 𝕩.

↗️
     b  25  10
 ┌─           
@@ -172,7 +172,7 @@
 ↗️
    b  ⟨⟩ / b
 1
 
-

Indices

+

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.

↗️
    / 3012
 ⟨ 0 0 0 2 3 3 ⟩
@@ -212,7 +212,7 @@
       ┘
 

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

+

Inverse

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

↗️
    / 321
 ⟨ 0 0 0 1 1 2 ⟩
-- 
cgit v1.2.3