diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-09-03 13:15:32 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-09-03 13:15:32 -0400 |
| commit | dbaefcd18e98d1cad4609766b82e4e31758a7619 (patch) | |
| tree | d0dec17d58663a34ebfe192bf87b0242c4dfff41 /doc | |
| parent | d48d315a184d3d7110eebb24dc886b86d7d0e00f (diff) | |
Describe affine properties of character type
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/types.md | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/types.md b/doc/types.md index 168b2f16..ed8141a1 100644 --- a/doc/types.md +++ b/doc/types.md @@ -29,6 +29,11 @@ The BQN spec allows for different numeric models to be used, but requires there A character in BQN is always a [Unicode](https://en.wikipedia.org/wiki/Unicode) code point. BQN does not use encodings such as UTF-8 or UTF-16 for characters, although it would be possible to store arrays of integers or characters that correspond to data in these encodings. Because every code point corresponds to a single unit in UTF-32, BQN characters can be thought of as UTF-32 encoded. +Addition and subtraction treat characters as an [affine space](http://videocortex.io/2018/Affine-Space-Types/) relative to the linear space of numbers. This means that: +* A number can be added to or subtracted from a character. +* Two characters can be subtracted to get the distance between them—a number. +Other linear combinations such as adding two characters or negating a character are not allowed. You can check whether an application of `+` or `-` on numbers and characters is allowed by applying the same function to the "characterness" of each value: `0` for a number and `1` for a character. The result will be a number if this application gives `0` and a character if this gives `1`, and otherwise the operation is not allowed. + ### Arrays A BQN array is a multidimensional arrangement of data. |
