diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-01-28 20:56:46 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-01-28 21:02:27 -0500 |
| commit | 9cfc45f731a121282f47218d6ab80c5b9b06e277 (patch) | |
| tree | e5934a40c9c3e94651d767472369bfa7a38113f3 /help | |
| parent | 0c716e4c6b7c2c44bbfd02b6503cae66af7b7480 (diff) | |
Add ;:? to keybar and help
Diffstat (limited to 'help')
| -rw-r--r-- | help/README.md | 3 | ||||
| -rwxr-xr-x | help/genhelp.bqn | 7 | ||||
| -rw-r--r-- | help/header.md | 20 | ||||
| -rw-r--r-- | help/nextbody.md | 16 | ||||
| -rw-r--r-- | help/predicate.md | 16 |
5 files changed, 60 insertions, 2 deletions
diff --git a/help/README.md b/help/README.md index 0571a25b..011d7459 100644 --- a/help/README.md +++ b/help/README.md @@ -47,6 +47,7 @@ Symbols are listed in alphabetical order of page name, ignoring syntactical role | `⍋` | [Grade Up, Bins Up](gradeup_binsup.md) | | `≥` | [Greater Than or Equal To](greaterthanorequalto.md) | | `⊔` | [Group Indices, Group](groupindices_group.md) | +| `:` | [Header](header.md) | | `⊣` | [Identity, Left](identity_left.md) | | `⊢` | [Identity, Right](identity_right.md) | | `/` | [Indices, Replicate](indices_replicate.md) | @@ -62,12 +63,14 @@ Symbols are listed in alphabetical order of page name, ignoring syntactical role | `𝔽` | [Modifier Left operand](modifierleftoperand.md) | | `.` | [Namespace Field](namespacefield.md) | | `-` | [Negate, Subtract](negate_subtract.md) | +| `;` | [Next Body](nextbody.md) | | `·` | [Nothing](nothing.md) | | `¬` | [Logical Not, Span](not_span.md) | | `@` | [Null Character](nullcharacter.md) | | `⊒` | [Occurrence Count, Progressive Index Of](occurrencecount_progressiveindexof.md) | | `○` | [Atop, Over](over.md) | | `π` | [Pi](pi.md) | +| `?` | [Predicate](predicate.md) | | `↑` | [Prefixes, Take](prefixes_take.md) | | `↕` | [Range, Windows](range_windows.md) | | `=` | [Rank, Equal To](rank_equals.md) | diff --git a/help/genhelp.bqn b/help/genhelp.bqn index 2cdfe2b6..4bf27e09 100755 --- a/help/genhelp.bqn +++ b/help/genhelp.bqn @@ -1,13 +1,16 @@ #!/usr/bin/env bqn +files ← "README.md"⊸≢¨⊸/ (⍋(¬∊⟜"_.")⊸/¨)⊸⊏ ".md"⊸(-∘≠⊸↑≡⊣)¨⊸/ •file.List "" + thing ← { data ← •FLines 𝕩 - names ← (⊣∾", "∾⊢)´{(¬·∧`' '⊸=)⊸/⌾⌽(2+⊑/':'=𝕩)↓𝕩}¨("## "≡3⊸↑)¨⊸/data + names ← (⊣∾", "∾⊢)´{(¬·∧`' '⊸=)⊸/⌾⌽(»·∧`⌾⌽':'⊸≠)⊸/𝕩}¨("## "≡3⊸↑)¨⊸/data t‿d ← ∾/¨(⊏data)=¨"()" sym ← (+`·»⊸-˝(¬»∧«)∘=⟜'`'∧⎉1"()"=⌜⊢)⊸/ 2⊑data sym (1+'|'⊸=)⊸(/+(-´"\|")×{«⊒/𝕨})↩ + sym "`,` or `⋄`"⍟("`,``⋄`"⊸≡)↩ "| " ∾ sym ∾ " | [" ∾ names ∾ "]("∾𝕩∾ ") |" -}¨•args(¬∘∊/⊣)⟨"README.md"⟩ +}¨ files head ← ⟨ "*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/help/index.html).*" diff --git a/help/header.md b/help/header.md new file mode 100644 index 00000000..c881943a --- /dev/null +++ b/help/header.md @@ -0,0 +1,20 @@ +*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/help/header.html).* + +# Colon (`:`) + +## `:`: Header +[→full documentation](../doc/block.md#block-headers) + +Placed at the end of a block header. A header has syntax that matches the way the block is called. It indicates the block type, and number and structure of inputs. + + "xy" {a‿b _op c: b} ∞ + +Multiple bodies are searched in order to find one with a matching header. + + F ← {m Fn n: m+Fn n; 𝕊n: 2×n; 𝕊⁼𝕩: 𝕩÷2} + + F 3 # 𝕊n + + F⁼ 6 # 𝕊⁼𝕩 + + 10 F 3 # m Fn n diff --git a/help/nextbody.md b/help/nextbody.md new file mode 100644 index 00000000..02cc710c --- /dev/null +++ b/help/nextbody.md @@ -0,0 +1,16 @@ +*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/help/nextbody.html).* + +# Semicolon (`;`) + +## `;`: Next Body +[→full documentation](../doc/block.md#multiple-bodies) + +End the current block body and start a new one. [Headers](header.md) (`:`) and [predicates](predicate.md) (`?`) can control which body is evaluated. A function can have two headers without these, indicating the monadic and dyadic cases. + + 3 { 𝕩÷2 ; -𝕨‿𝕩 } 4 # Monadic and dyadic cases + + F ← {𝕊a‿b: a-b; 𝕊a‿b‿c: b+c} + + F 5‿2 # Matches first header + + F 1‿3‿6 # Matches second header diff --git a/help/predicate.md b/help/predicate.md new file mode 100644 index 00000000..eefd390a --- /dev/null +++ b/help/predicate.md @@ -0,0 +1,16 @@ +*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/help/predicate.html).* + +# Question Mark (`?`) + +## `?`: Predicate +[→full documentation](../doc/block.md#predicates) + +Follows a statement in a block, which must return 0 or 1. If it's 0, stop the current body and evaluate the next eligible one instead. Variables defined before the `?` stay if execution continues (1) but don't carry over to other bodies (0). + + {0 ? 3 ; 4} + + Min ← {𝕨<𝕩 ? 𝕨 ; 𝕩} + + 3 Min 5 + + 4 Min 2 |
