diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/arithmetic.md | 4 | ||||
| -rw-r--r-- | doc/logic.md | 4 | ||||
| -rw-r--r-- | doc/search.md | 4 | ||||
| -rw-r--r-- | doc/transpose.md | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/doc/arithmetic.md b/doc/arithmetic.md index 03b02c3c..9497b8fe 100644 --- a/doc/arithmetic.md +++ b/doc/arithmetic.md @@ -2,9 +2,9 @@ # Arithmetic functions -BQN's arithmetic functions use mostly the same symbols as APL, and the functionality is actually defined by the language implementation's number system and not the specification, so there's not too much to say about them. +Since BQN's function syntax was designed to mirror mathematical operators, its arithmetic tends to look a lot like mathematical notation. Individual functions are listed below. As an array language, BQN applies arithmetic element-wise to arrays, a system known as [pervasion](#pervasion). A distinctive feature of BQN is its [character arithmetic](#character-arithmetic), which allows `+` and `-` to manipulate characters without explicitly transforming them to numbers. -Summary of differences for APLers: +Summary of other differences from APL: - Exponentiation is represented with the star character `⋆`, since asterisk `*` is rendered inconsistently across fonts and sometimes appears as a superscript. - There's a root function `√`. - Not uses a different symbol `¬`, and binary logical functions `∧∨` (described on [their own page](logic.md)) are extended linearly in all arguments instead of using GCD or LCM. diff --git a/doc/logic.md b/doc/logic.md index 90090e38..080e54f1 100644 --- a/doc/logic.md +++ b/doc/logic.md @@ -2,7 +2,7 @@ # Logic functions: And, Or, Not (also Span) -BQN retains the APL symbols `∧` and `∨` for logical *and* and *or*, and changed APL's `~` to `¬` for *not*, since `~` looks too much like `˜` and `¬` is more common in mathematics today. Like J, BQN extends Not to the linear function `1⊸-`. However, it discards [GCD](https://aplwiki.com/wiki/GCD) and [LCM](https://aplwiki.com/wiki/LCM) as extensions of And and Or, and instead uses bilinear extensions: And is identical to Times (`×`), while Or is `×⌾¬`, following De Morgan's laws (other ways of obtaining a function for Or give an equivalent result—there is only one bilinear extension). +BQN uses the mathematical symbols `∧` and `∨` for logical *and* and *or*, and `¬` for *not* (APL's `~` is discarded since it looks like `˜`, and is less common in mathematics today). These functions are arithmetically extended to apply to all numbers. In the case of Not, that means the linear function `1⊸-`. The two-argument functions have bilinear extensions: And is identical to Times (`×`), while Or is `×⌾¬`, following De Morgan's laws (other ways of obtaining a function for Or give an equivalent result—there is only one bilinear extension). If the arguments are probabilities of independent events, then an extended function gives the probability of the boolean function on their outcomes (for example, if *A* occurs with probability `a` and *B* with probability `b` independent of *A*, then *A* or *B* occurs with probability `a∨b`). These extensions have also been used in complexity theory, because they allow mathematicians to transfer a logical circuit from the discrete to the continuous domain in order to use calculus on it. @@ -36,7 +36,7 @@ As with logical And and Or, any value and 0 is 0, while any value or 1 is 1. The ## Why not GCD and LCM? -The main reason for omitting these functions is that they are complicated and, when applied to real or complex numbers, require a significant number of design decisions where there is no obvious choice (for example, whether to use comparison tolerance). On the other hand, these functions are fairly easy to implement, which allows the programmer to control the details, and also add functionality such as the extended GCD. Possible implementations for GCD and LCM are shown in [bqncrate](https://mlochbaum.github.io/bqncrate) ([GCD](https://mlochbaum.github.io/bqncrate/?q=gcd), [LCM](https://mlochbaum.github.io/bqncrate/?q=lcm)). +APL provides [GCD](https://aplwiki.com/wiki/GCD) and [LCM](https://aplwiki.com/wiki/LCM) as extensions of And and Or, while BQN doesn't make these functions primitives. The main reason for omitting them functions is that they are complicated and, when applied to real or complex numbers, require a significant number of design decisions where there is no obvious choice (for example, whether to use comparison tolerance). On the other hand, these functions are fairly easy to implement, which allows the programmer to control the details, and also add functionality such as the extended GCD. Possible implementations for GCD and LCM are shown in [bqncrate](https://mlochbaum.github.io/bqncrate) ([GCD](https://mlochbaum.github.io/bqncrate/?q=gcd), [LCM](https://mlochbaum.github.io/bqncrate/?q=lcm)). A secondary reason is that the GCD falls short as an extension of Or, because its identity value 0 is not total. `0∨x`, for a real number `x`, is actually equal to `|x` and not `x`: for example, `0∨¯2` is `2` in APL. This means the identity `0∨x ←→ x` isn't reliable in APL. diff --git a/doc/search.md b/doc/search.md index 5a093dc7..7c0aa7dd 100644 --- a/doc/search.md +++ b/doc/search.md @@ -71,7 +71,7 @@ Member of can be used in a [train](train.md) to compute the set intersection and "initial set" (¬∘∊/⊣) "difference" # Remove 𝕩 -These are the APL functions Intersect (`∩`) and Without (`~`). Really, only `𝕩` is treated like a set, while the ordering and multiplicity of elements of `𝕨` are maintained. I think the explicit implementations show this well, since `𝕩` is only used as the right argument to `∊`, and prefer this clarity to the brevity of a single symbol. +These functions appear in APL as Intersect (`∩`) and Without (`~`). Really, only `𝕩` is treated like a set, while the ordering and multiplicity of elements of `𝕨` are maintained. I think the explicit implementations show this well, since `𝕩` is only used as the right argument to `∊`, and prefer this clarity to the brevity of a single symbol. ## Index of @@ -103,7 +103,7 @@ Above we said that `𝕩∊𝕨` is `(𝕨⊐𝕩)<≠𝕨`, so that `⊐˜<≠ "aabbcc" ((⊒˜=≠∘⊢)/⊣) "baa" # Multiset difference -This primitive gives an interesting way to implement the [ordinals](order.md#ordinals) pattern that might be easier to understand than the APL classic `⍋⍋` (it's probably a little slower though). The idea is to use the sorted array as the left argument to `⊒`. Now the index returned for each cell is just where it ended up in that sorted order. If we used ordinary Index of then equal cells would share the smallest index; Progressive Index of means ties are broken in favor of earlier cells. +This primitive gives an interesting way to implement the [ordinals](order.md#ordinals) pattern that might be easier to understand than the classic `⍋⍋` (it's probably a little slower though). The idea is to use the sorted array as the left argument to `⊒`. Now the index returned for each cell is just where it ended up in that sorted order. If we used ordinary Index of then equal cells would share the smallest index; Progressive Index of means ties are broken in favor of earlier cells. ⍋∘⍋ "adebcedba" diff --git a/doc/transpose.md b/doc/transpose.md index d7718b5e..64d1cbe2 100644 --- a/doc/transpose.md +++ b/doc/transpose.md @@ -2,7 +2,7 @@ # Transpose -Transpose (`⍉`) is a tool for rearranging the axes of an array. BQN's version is tweaked relative to APL to align better with the leading axis model and make common operations easier. +Transpose (`⍉`) is a tool for rearranging the axes of an array `𝕩`. Without a left argument, it moves the first axis to the end, while a left argument can specify an arbitrary rearrangement. Both cases are tweaked relative to APL to align better with the [leading axis](leading.md) model and make common operations easier. ## Transpose basics @@ -77,7 +77,7 @@ Since this kind of rearrangement can be counterintuitive, it's often easier to u ≢ 1‿3‿2‿0‿4 ⍉⁼ a23456 -So far, all like APL. BQN makes one little extension, which is to allow only some axes to be specified. Then `𝕨` will be matched up with [leading axes](leading.md) of `𝕩`. Those axes are moved according to `𝕨`, and remaining axes are placed in order into the gaps between them. +BQN makes one further extension, which is to allow only some axes to be specified (this is the only difference in dyadic `⍉` relative to APL). Then `𝕨` will be matched up with [leading axes](leading.md) of `𝕩`. Those axes are moved according to `𝕨`, and remaining axes are placed in order into the gaps between them. ≢ 0‿2‿4 ⍉ a23456 |
