diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-11-03 15:51:15 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-11-03 15:55:14 -0400 |
| commit | 29509cedb9af2715328e44c481738a9ba05cff73 (patch) | |
| tree | 734a0251dbb20bc7e29b4b0e3bac3b48e0cdaff0 /doc | |
| parent | 30b5188c23576d5e119bbc8d27cd08a3015a75c9 (diff) | |
Use ⋈ rather than ≍○< in documentation examples
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/couple.md | 5 | ||||
| -rw-r--r-- | doc/fold.md | 10 | ||||
| -rw-r--r-- | doc/reverse.md | 8 | ||||
| -rw-r--r-- | doc/transpose.md | 4 |
4 files changed, 12 insertions, 15 deletions
diff --git a/doc/couple.md b/doc/couple.md index 95806d8f..51309b18 100644 --- a/doc/couple.md +++ b/doc/couple.md @@ -42,10 +42,7 @@ Above we start with a list of three empty arrays. After merging once we get a sh A note on the topic of Solo and Couple applied to units. As always, one axis will be added, so that the result is a list (strangely, J's [laminate](https://code.jsoftware.com/wiki/Vocabulary/commaco#dyadic) differs from Couple in this one case, as it will add an axis to get a shape `2‿1` result). For Solo, this is interchangeable with [Deshape](reshape.md) (`⥊`), and either primitive might be chosen for stylistic reasons. For Couple, it is equivalent to [Join-to](join.md) (`∾`), but this is an irregular form of Join-to because it is the only case where Join-to adds an axis to both arguments instead of just one. Couple should be preferred in this case. -The pair function, which creates a list from its arguments, can be written `Pair ← ≍○<`, while `≍` in either valence is `>∘Pair`. As an interesting consequence, `≍ ←→ >∘≍○<`, and the same relationship holds for `Pair`. - - ⟨2,3⟩ ≍○< "abc" # Pair two values - ≍○< "abc" # Pair one(?) value +The function [Pair](pair.md) (`⋈`) can be written `≍○<`, while `≍` in either valence is `>∘⋈`. As an interesting consequence, `≍ ←→ >∘≍○<`, and `⋈ ←→ >∘⋈○<`. These two identities have the same form because adding `○<` commutes with adding `>∘`. ## Definitions diff --git a/doc/fold.md b/doc/fold.md index e27b7f02..f17a6f62 100644 --- a/doc/fold.md +++ b/doc/fold.md @@ -96,15 +96,15 @@ The full list of identity values Fold has to use is shown below. The functions we've shown so far are associative (ignoring floating point imprecision), meaning it's equally valid to combine elements of the argument list in any order. But it can be useful to fold using a non-associative function. In this case you must know that Fold performs a *right fold*, starting from the end of the array and working towards the beginning. - ≍○<´ "abcd" + ⋈´ "abcd" - 'a' ≍○< 'b' ≍○< 'c' ≍○< 'd' # Expanded form + 'a' ⋈ 'b' ⋈ 'c' ⋈ 'd' # Expanded form -Using the [pair](couple.md#coupling-units) function `≍○<` as an operand shows the structure nicely. This fold first pairs the final two characters `'c'` and `'d'`, then pairs `'b'` with that and so on. This matches BQN's right-to-left order of evaluation. More declaratively we might say that each character is paired with the result of folding over everything to its right. +Using [Pair](pair.md) (`⋈`) as an operand shows the structure nicely. This fold first pairs the final two characters `'c'` and `'d'`, then pairs `'b'` with that and so on. This matches BQN's right-to-left order of evaluation. More declaratively we might say that each character is paired with the result of folding over everything to its right. BQN doesn't provide a left Fold (`` ` `` is [Scan](scan.md)). However, you can fold from the left by [reversing](reverse.md#reverse) (`⌽`) the argument list and also reversing (`˜`) the operand function's argument order. - ≍○<˜´ ⌽ "abcd" + ⋈˜´ ⌽ "abcd" One consequence of this ordering is that folding with Minus (`-`) gives an alternating sum, where the first value is added, the second subtracted, the third added, and so on. Similarly, `÷` gives an alternating product, with some elements multiplied and some divided. @@ -159,7 +159,7 @@ A function with Insert `𝔽˝` is nearly equivalent to `𝔽´<˘` (and both fa Just like Fold, Insert allows an initial element for the left argument, so that you don't need to rely on the interpreter knowing the identity. A more complete translation into Fold is therefore `{𝕨𝔽´<˘𝕩}`. The expression below shows that the operand function is called on the last major cell when the identity, then the next-to-last major cell and so on. In total there are `≠𝕩` calls, while there would be `1-˜≠𝕩` without the left argument. - "id" ≍○<˝ "row0 "∾"row1 "≍"row2 " + "id" ⋈˝ "row0 "∾"row1 "≍"row2 " One trick involving Insert is `∾˝`, which merges the first two axes of `𝕩` into one long axis. It even works on empty arrays, because BQN knows that there's only one result shape that makes sense (in contrast to `∾´⟨⟩`, where many results sometimes work but none of them always work). diff --git a/doc/reverse.md b/doc/reverse.md index 5a1e2f37..f2a20281 100644 --- a/doc/reverse.md +++ b/doc/reverse.md @@ -22,11 +22,11 @@ To reverse along an axis other than the first, use Cells (`˘`) or Rank (`⎉`). ⌽˘ >"ab"‿"cd"‿"ef" -Reverse is useful for [folding](fold.md) left to right instead of right to left. +Reverse is useful for [folding](fold.md) left to right instead of right to left (here we use [Pair](pair.md) to show structure). - ≍○< ´ "abcd" # Right to left + ⋈ ´ "abcd" # Right to left - ≍○<˜´ ⌽ "abcd" # Left to right + ⋈˜´ ⌽ "abcd" # Left to right Reverse is its own [inverse](undo.md) `⌽⁼`. As a result, `𝔽⌾⌽` reverses the argument, applies `𝔽`, and reverses again. It's a particularly useful pattern with [Scan](scan.md), as it allows scanning from the end rather than the beginning of the array. For example, `` ∨` `` on a list of booleans changes all bits after the first `1` to `1`, but `` ∨`⌾⌽ `` does this to all bits before the last `1`. @@ -40,7 +40,7 @@ Rotate moves elements in a list around cyclically. It can also rotate any number 2 ⌽ "rotate" - 2 (⊢ ≍○< ⌽) 5‿2⥊"rotateCELL" + 2 (⊢ ⋈ ⌽) 5‿2⥊"rotateCELL" 2 ⌽ 'c' # No axes to rotate diff --git a/doc/transpose.md b/doc/transpose.md index 7f91ad2d..d7718b5e 100644 --- a/doc/transpose.md +++ b/doc/transpose.md @@ -31,11 +31,11 @@ BQN's transpose takes the first axis of `𝕩` and moves it to the end. In terms of the argument data as given by [Deshape](reshape.md#deshape) (`⥊`), this looks like a simple 2-dimensional transpose: one axis is exchanged with a compound axis made up of the other axes. Here we transpose a rank 3 matrix: a322 ← 3‿2‿2⥊↕12 - ≍○<⟜⍉ a322 + ⋈⟜⍉ a322 But, ignoring the whitespace and going in reading order, the argument and result have exactly the same element ordering as for the rank 2 matrix `⥊˘ a322`: - ≍○<⟜⍉ ⥊˘ a322 + ⋈⟜⍉ ⥊˘ a322 To exchange multiple axes, use the [Repeat](repeat.md) modifier. A negative power moves axes in the other direction, just like how [Rotate](reverse.md#rotate) handles negative left arguments. In particular, to move the last axis to the front, use [Undo](undo.md) (as you might expect, this exactly inverts `⍉`). |
