aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/group.md10
-rw-r--r--doc/join.md6
-rw-r--r--doc/logic.md2
-rw-r--r--doc/transpose.md6
4 files changed, 12 insertions, 12 deletions
diff --git a/doc/group.md b/doc/group.md
index c149716c..b561cd7d 100644
--- a/doc/group.md
+++ b/doc/group.md
@@ -12,12 +12,12 @@ Once defined, the old BQN Key (dyadic) is `⍷⊸⊐⊸⊔` and Group (monadic)
Group operates on a numeric list of indices and a value array, treated as a list of its major cells, to produce a list of groups, each of which is a selection from the values. The indices and values have the same length, and each value cell is paired with the index at the same position. That index indicates the result group the value should go into, with an "index" of ¯1 indicating that it should be dropped and not appear in the result.
- 0‿1‿2‿0‿1 ≍ "abcde" ⍝ Corresponding indices and values
+ 0‿1‿2‿0‿1 ≍ "abcde" # Corresponding indices and values
0 1 2 0 1
a b c d e
- 0‿1‿2‿0‿1 ⊔ "abcde" ⍝ Values grouped by index
+ 0‿1‿2‿0‿1 ⊔ "abcde" # Values grouped by index
[ [ ad ] [ be ] [ c ] ]
For example, we might choose to group a list of words by length. Within each group, values maintain the ordering they had in the list originally.
@@ -168,14 +168,14 @@ In other cases, we might want to split on spaces, so that words are separated by
However, trailing spaces are ignored because Group never produces trailing empty groups (to get them back we would use a dummy final character in the string). To avoid empty words, we should increase the word index only once per group of spaces. We can do this by taking the prefix sum of a list that is 1 only for a space with no space before it. To make such a list, we can use the [Windows](windows.md) function. We will extend our list with an initial 1 so that leading spaces will be ignored. Then we take windows of the same length as the original list: the first includes the dummy argument followed by a shifted copy of the list, and the second is the original list. These represent whether the previous and current characters are spaces; we want positions where the previous wasn't a space and the current is.
- ≍⟜((<´<˘)≠↕1∾⊢) ' '=" string with spaces " ⍝ All, then filtered, spaces
+ ≍⟜((<´<˘)≠↕1∾⊢) ' '=" string with spaces " # All, then filtered, spaces
1 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0
- ≍⟜(⊢-˜¬×+`∘((<´<˘)≠↕1∾⊢))' '=" string with spaces " ⍝ More processing
+ ≍⟜(⊢-˜¬×+`∘((<´<˘)≠↕1∾⊢))' '=" string with spaces " # More processing
1 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 1 1
¯1 ¯1 0 0 0 0 0 0 ¯1 1 1 1 1 ¯1 ¯1 2 2 2 2 2 2 ¯1 ¯1 ¯1
- ' '((⊢-˜¬×+`∘((<´<˘)≠↕1∾⊢))∘=⊔⊢)" string with spaces " ⍝ Final result
+ ' '((⊢-˜¬×+`∘((<´<˘)≠↕1∾⊢))∘=⊔⊢)" string with spaces " # Final result
[ [ string ] [ with ] [ spaces ] ]
diff --git a/doc/join.md b/doc/join.md
index f11b815a..cb8dfb36 100644
--- a/doc/join.md
+++ b/doc/join.md
@@ -12,9 +12,9 @@ To join with a separator in between, we might prepend the separator to each stri
Join requires each element of its argument to be an array, and their ranks to match exactly. No rank extension is performed.
- ∾"abc"‿'d'‿"ef" ⍝ Includes a non-array
+ ∾"abc"‿'d'‿"ef" # Includes a non-array
RANK ERROR
- ∾"abc"‿(<'d')‿"ef" ⍝ Includes a scalar
+ ∾"abc"‿(<'d')‿"ef" # Includes a scalar
RANK ERROR
However, Join has higher-dimensional uses as well. Given a rank-`m` array of rank-`n` arrays (requiring `m≤n`), it will merge arrays along their first `m` axes. For example, if the argument is a matrix of matrices representing a [block matrix](https://en.wikipedia.org/wiki/Block_matrix), Join will give the corresponding unblocked matrix as its result.
@@ -28,7 +28,7 @@ However, Join has higher-dimensional uses as well. Given a rank-`m` array of ran
┘ ┘ ┘
[ 3 3 3 3 ] [ 4 4 ] [ 5 5 5 5 5 ]
- ∾ m ⍝ Join all that together
+ ∾ m # Join all that together
0 0 0 0 1 1 2 2 2 2 2
0 0 0 0 1 1 2 2 2 2 2
diff --git a/doc/logic.md b/doc/logic.md
index d3bbde18..0e38fb1d 100644
--- a/doc/logic.md
+++ b/doc/logic.md
@@ -10,7 +10,7 @@ Both valences of `¬` are equivalent to the fork `1+-`. The dyadic valence, call
We define:
- Not ← 1+- ⍝ also Span
+ Not ← 1+- # also Span
And ← ×
Or ← ×⌾¬
diff --git a/doc/transpose.md b/doc/transpose.md
index e13b6691..006f0de6 100644
--- a/doc/transpose.md
+++ b/doc/transpose.md
@@ -69,7 +69,7 @@ Certainly not as concise as APL's version, but not a horror either. BQN's rule i
Axis permutations of the types we've shown generate the complete permutation group on any number of axes, so you could produce any transposition you want with the right sequence of monadic transpositions with Rank. However, this can be unintuitive and tedious. What if you want to transpose the first three axes, leaving the rest alone? With monadic Transpose you have to send some axes to the end, then bring them back to the beginning. For example [following four or five failed tries]:
- ≢ ⍉⁼⎉¯2 ⍉ a23456 ⍝ Restrict Transpose to the first three axes
+ ≢ ⍉⁼⎉¯2 ⍉ a23456 # Restrict Transpose to the first three axes
[ 3 4 2 5 6 ]
In a case like this BQN's Dyadic transpose is much easier.
@@ -80,7 +80,7 @@ Transpose also allows a left argument that specifies a permutation of the right
≢ 1‿3‿2‿0‿4 ⍉ a23456
[ 5 2 4 3 6 ]
- ≢ 1‿2‿2‿0‿0 ⍉ a23456 ⍝ Don't worry too much about this case though
+ ≢ 1‿2‿2‿0‿0 ⍉ a23456 # Don't worry too much about this case though
[ 5 2 3 ]
Since this kind of rearrangement can be counterintuitive, it's often easier to use `⍉⁼` when specifying all axes. If `p≡○≠≢a`, then we have `≢p⍉⁼a ←→ p⊏≢a`.
@@ -95,7 +95,7 @@ So far, all like APL. BQN makes one little extension, which is to allow only som
In particular, the case with only one argument specified is interesting. Here, the first axis ends up at the given location. This gives us a much better solution to the problem at the end of the last section.
- ≢ 2 ⍉ a23456 ⍝ Restrict Transpose to the first three axes
+ ≢ 2 ⍉ a23456 # Restrict Transpose to the first three axes
[ 3 4 2 5 6 ]
Finally, it's worth noting that, as monadic Transpose moves the first axis to the end, it's equivalent to dyadic Transpose with a "default" left argument: `(≠∘≢-1˜)⊸⍉`.