diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-06-26 10:17:17 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-06-26 10:17:17 -0400 |
| commit | f34e14170e1fb9b962d88316b7089192e07b2025 (patch) | |
| tree | 5255a0cebb44830f4ca083e7fbdf6c4351f63e52 | |
| parent | f0ce6d9304f3d010c11aa482093c407d86ca0f05 (diff) | |
Add Valences and Choose operators everywhere
| -rw-r--r-- | README.md | 10 | ||||
| -rwxr-xr-x | c.bqn | 2 | ||||
| -rw-r--r-- | doc/context.md | 2 | ||||
| -rw-r--r-- | spec/token.md | 2 |
4 files changed, 9 insertions, 7 deletions
@@ -60,7 +60,7 @@ Unlike APL, in BQN the syntactic role of a value is determined purely by the way 1 2 3 ┘ -BQN's built-in operations also have patterns to indicate the syntactic role: modifiers (`` ˜¨˘⁼⌜´` ``) are all superscript characters, and compositions (`∘○⊸⟜⌾⚇⎉⍟`) all have an unbroken circle (two functions `⌽⍉` have broken circles with lines through them). Every other built-in constant is a function, although the special symbols `¯`, `∞`, and `π` are used as part of numeric literal notation. +BQN's built-in operations also have patterns to indicate the syntactic role: modifiers (`` ˜¨˘⁼⌜´` ``) are all superscript characters, and compositions (`∘○⊸⟜⌾⊘◶⚇⎉⍟`) all have an unbroken circle (two functions `⌽⍉` have broken circles with lines through them). Every other built-in constant is a function, although the special symbols `¯`, `∞`, and `π` are used as part of numeric literal notation. ### Special syntax @@ -140,11 +140,13 @@ Glyph | Name(s) | Definition | Description `˜` | Self/Swap | `{𝕩𝔽𝕨⊣𝕩}` | Duplicate one argument or exchange two `∘` | Atop | `{𝔽𝕨𝔾𝕩}` | Apply `𝔾` to both arguments and `𝔽` to the result `○` | Over | `{(𝔾𝕨)𝔽𝔾𝕩}` | Apply `𝔾` to each argument and `𝔽` to the results -`⊸` | Before/Bind | `{(𝔽𝕨)𝔾𝕩}˜˜` | `𝔾`'s left argument comes from `𝔽` -`⟜` | After/Bind | `{𝕨𝔽𝔾𝕩}˜˜` | `𝔽`'s right argument comes from `𝔾` +`⊸` | Before/Bind | `{(𝔽𝕨⊣𝕩)𝔾𝕩}` | `𝔾`'s left argument comes from `𝔽` +`⟜` | After/Bind | `{(𝕨⊣𝕩)𝔽𝔾𝕩}` | `𝔽`'s right argument comes from `𝔾` `⌾` | Under | `{𝔾⁼∘𝔽○𝔾}` OR `{(𝔾𝕩)↩𝕨𝔽○𝔾𝕩⋄𝕩}` | Apply `𝔽` over `𝔾`, then undo `𝔾` +`⊘` | Valences | `{𝔽𝕩;𝕨𝔾𝕩}` | Apply `𝔽` if there's one argument but `𝔾` if there are two +`◶` | Choose | `{f←(𝕨𝔽𝕩)⊑𝕘 ⋄ 𝕨F𝕩}` | Select one of the functions in list `𝕘` based on `𝔽` -Under is not a true combinator since it has an "undo" step at the end. This step might be implemented using the left operand's inverse (*computational* Under) or its structural properties (*structural* Under). +Choose isn't really a combinator since it calls the function `⊑`, and Under is not a true combinator since it has an "undo" step at the end. This step might be implemented using the left operand's inverse (*computational* Under) or its structural properties (*structural* Under). Other modifiers and compositions control array traversal and iteration. In three cases a simpler modifier is paired with a generalized composition: in each case the modifier happens to be the same as the composition with a right operand of `¯1`. @@ -16,7 +16,7 @@ charSet←∾charGroups←⟨ "_"∾' '(⊢∾+)⌾•UCS•a ⍝ Alphabetic chF←"+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔" ⍝ Function "˜˘¨⌜⁼´`" ⍝ Modifier - "∘○⊸⟜⌾⎉⚇⍟" ⍝ Composition + "∘○⊸⟜⌾⊘◶⎉⚇⍟" ⍝ Composition "𝕨𝕎𝕩𝕏𝕗𝔽𝕘𝔾" ⍝ Parameter " "∾tab ⍝ Whitespace lf∾"⋄," ⍝ Separator diff --git a/doc/context.md b/doc/context.md index 0aab2b93..f37e36b3 100644 --- a/doc/context.md +++ b/doc/context.md @@ -36,7 +36,7 @@ BQN's expression grammar is a simplified version of the typical APL, removing so | Modifier | Monadic operator | Adverb | Composition | Dyadic operator | Conjunction -BQN primitives have only one spelling, and a fixed role (but their values can be used in a different role by storing them in variables). Superscript glyphs `` ˜¨˘⁼⌜´` `` are used for modifiers, and glyphs `∘○⊸⟜⌾⚇⎉⍟◶⊘` with an unbroken circle are compositions. Other primitives are functions. String and numeric literals are values. +BQN primitives have only one spelling, and a fixed role (but their values can be used in a different role by storing them in variables). Superscript glyphs `` ˜¨˘⁼⌜´` `` are used for modifiers, and glyphs `∘○⊸⟜⌾⊘◶⚇⎉⍟` with an unbroken circle are compositions. Other primitives are functions. String and numeric literals are values. BQN's variables use another system. Unlike primitives, variables can be spelled as any of the four syntactic types. Its value remains the same, as the spelling only indicates how this value is used. A variable spelled with a lowercase first letter, like `var`, is a value. Spelled with an uppercase first letter, like `Var`, it is a function. Underscores are placed where operands apply to indicate a modifier `_var` or composition `_var_`. Other than the first letter or underscore, variables are case-insensitive. diff --git a/spec/token.md b/spec/token.md index 3ded7b5d..8e695139 100644 --- a/spec/token.md +++ b/spec/token.md @@ -16,7 +16,7 @@ Otherwise, a single character forms a token. Only the specified set of character |-----------------------|------------ | Primitive Function | `+-×÷⋆√⌊⌈\|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔` | Primitive Modifier | `` ˜˘¨⌜⁼´` `` -| Primitive Composition | `∘○⊸⟜⌾⎉⚇⍟` +| Primitive Composition | `∘○⊸⟜⌾⊘◶⎉⚇⍟` | Parameter | `𝕨𝕩𝕗𝕘𝕎𝕏𝔽𝔾` | Punctuation | `←↩→(){}⟨⟩‿⋄,` and newline |
