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 | |
| parent | 0c716e4c6b7c2c44bbfd02b6503cae66af7b7480 (diff) | |
Add ;:? to keybar and help
| -rw-r--r-- | docs/help/header.html | 25 | ||||
| -rw-r--r-- | docs/help/index.html | 12 | ||||
| -rw-r--r-- | docs/help/nextbody.html | 21 | ||||
| -rw-r--r-- | docs/help/predicate.html | 21 | ||||
| -rw-r--r-- | docs/repl.js | 4 | ||||
| -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 |
10 files changed, 141 insertions, 4 deletions
diff --git a/docs/help/header.html b/docs/help/header.html new file mode 100644 index 00000000..2dccabef --- /dev/null +++ b/docs/help/header.html @@ -0,0 +1,25 @@ +<head> + <link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/> + <link href="../style.css" rel="stylesheet"/> + <title>BQN Colon (:)</title> +</head> +<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div> +<h1 id="colon-"><a class="header" href="#colon-">Colon (<code><span class='Head'>:</span></code>)</a></h1> +<h2 id="-header"><a class="header" href="#-header"><code><span class='Head'>:</span></code>: Header</a></h2> +<p><a class="fulldoc" href="../doc/block.html#block-headers">→full documentation</a></p> +<p>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.</p> +<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Inh5IiB7YeKAv2IgX29wIGM6IGJ9IOKIng==">↗️</a><pre> <span class='String'>"xy"</span> <span class='Brace'>{</span><span class='Value'>a</span><span class='Ligature'>‿</span><span class='Value'>b</span> <span class='Modifier'>_op</span> <span class='Value'>c</span><span class='Head'>:</span> <span class='Value'>b</span><span class='Brace'>}</span> <span class='Number'>∞</span> +'y' +</pre> +<p>Multiple bodies are searched in order to find one with a matching header.</p> +<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=RiDihpAge20gRm4gbjogbStGbiBuOyAg8J2Vim46IDLDl247ICDwnZWK4oG88J2VqTog8J2VqcO3Mn0KCkYgMyAgICAgICMg8J2Vim4KCkbigbwgNiAgICAgIyDwnZWK4oG88J2VqQoKMTAgRiAzICAgIyBtIEZuIG4=">↗️</a><pre> <span class='Function'>F</span> <span class='Gets'>←</span> <span class='Brace'>{</span><span class='Value'>m</span> <span class='Function'>Fn</span> <span class='Value'>n</span><span class='Head'>:</span> <span class='Value'>m</span><span class='Function'>+Fn</span> <span class='Value'>n</span><span class='Head'>;</span> <span class='Function'>𝕊</span><span class='Value'>n</span><span class='Head'>:</span> <span class='Number'>2</span><span class='Function'>×</span><span class='Value'>n</span><span class='Head'>;</span> <span class='Function'>𝕊</span><span class='Modifier'>⁼</span><span class='Value'>𝕩</span><span class='Head'>:</span> <span class='Value'>𝕩</span><span class='Function'>÷</span><span class='Number'>2</span><span class='Brace'>}</span> + + <span class='Function'>F</span> <span class='Number'>3</span> <span class='Comment'># 𝕊n +</span>6 + + <span class='Function'>F</span><span class='Modifier'>⁼</span> <span class='Number'>6</span> <span class='Comment'># 𝕊⁼𝕩 +</span>3 + + <span class='Number'>10</span> <span class='Function'>F</span> <span class='Number'>3</span> <span class='Comment'># m Fn n +</span>16 +</pre> diff --git a/docs/help/index.html b/docs/help/index.html index 77f2dfa4..50372097 100644 --- a/docs/help/index.html +++ b/docs/help/index.html @@ -179,6 +179,10 @@ <td><a href="groupindices_group.html">Group Indices, Group</a></td> </tr> <tr> +<td><code><span class='Head'>:</span></code></td> +<td><a href="header.html">Header</a></td> +</tr> +<tr> <td><code><span class='Function'>⊣</span></code></td> <td><a href="identity_left.html">Identity, Left</a></td> </tr> @@ -239,6 +243,10 @@ <td><a href="negate_subtract.html">Negate, Subtract</a></td> </tr> <tr> +<td><code><span class='Head'>;</span></code></td> +<td><a href="nextbody.html">Next Body</a></td> +</tr> +<tr> <td><code><span class='Nothing'>·</span></code></td> <td><a href="nothing.html">Nothing</a></td> </tr> @@ -263,6 +271,10 @@ <td><a href="pi.html">Pi</a></td> </tr> <tr> +<td><code><span class='Head'>?</span></code></td> +<td><a href="predicate.html">Predicate</a></td> +</tr> +<tr> <td><code><span class='Function'>↑</span></code></td> <td><a href="prefixes_take.html">Prefixes, Take</a></td> </tr> diff --git a/docs/help/nextbody.html b/docs/help/nextbody.html new file mode 100644 index 00000000..f180ec55 --- /dev/null +++ b/docs/help/nextbody.html @@ -0,0 +1,21 @@ +<head> + <link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/> + <link href="../style.css" rel="stylesheet"/> + <title>BQN: Semicolon (;)</title> +</head> +<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div> +<h1 id="semicolon-"><a class="header" href="#semicolon-">Semicolon (<code><span class='Head'>;</span></code>)</a></h1> +<h2 id="-next-body"><a class="header" href="#-next-body"><code><span class='Head'>;</span></code>: Next Body</a></h2> +<p><a class="fulldoc" href="../doc/block.html#multiple-bodies">→full documentation</a></p> +<p>End the current block body and start a new one. <a href="header.html">Headers</a> (<code><span class='Head'>:</span></code>) and <a href="predicate.html">predicates</a> (<code><span class='Head'>?</span></code>) can control which body is evaluated. A function can have two headers without these, indicating the monadic and dyadic cases.</p> +<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MyB7IPCdlanDtzIgOyAt8J2VqOKAv/CdlakgfSA0ICAgIyBNb25hZGljIGFuZCBkeWFkaWMgY2FzZXMKCkYg4oaQIHvwnZWKYeKAv2I6IGEtYjsg8J2VimHigL9i4oC/YzogYitjfQoKRiA14oC/MiAgICAgICAgICAgICAgICAjIE1hdGNoZXMgZmlyc3QgaGVhZGVyCgpGIDHigL8z4oC/NiAgICAgICAgICAgICAgIyBNYXRjaGVzIHNlY29uZCBoZWFkZXI=">↗️</a><pre> <span class='Number'>3</span> <span class='Brace'>{</span> <span class='Value'>𝕩</span><span class='Function'>÷</span><span class='Number'>2</span> <span class='Head'>;</span> <span class='Function'>-</span><span class='Value'>𝕨</span><span class='Ligature'>‿</span><span class='Value'>𝕩</span> <span class='Brace'>}</span> <span class='Number'>4</span> <span class='Comment'># Monadic and dyadic cases +</span>⟨ ¯3 ¯4 ⟩ + + <span class='Function'>F</span> <span class='Gets'>←</span> <span class='Brace'>{</span><span class='Function'>𝕊</span><span class='Value'>a</span><span class='Ligature'>‿</span><span class='Value'>b</span><span class='Head'>:</span> <span class='Value'>a</span><span class='Function'>-</span><span class='Value'>b</span><span class='Head'>;</span> <span class='Function'>𝕊</span><span class='Value'>a</span><span class='Ligature'>‿</span><span class='Value'>b</span><span class='Ligature'>‿</span><span class='Value'>c</span><span class='Head'>:</span> <span class='Value'>b</span><span class='Function'>+</span><span class='Value'>c</span><span class='Brace'>}</span> + + <span class='Function'>F</span> <span class='Number'>5</span><span class='Ligature'>‿</span><span class='Number'>2</span> <span class='Comment'># Matches first header +</span>3 + + <span class='Function'>F</span> <span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>6</span> <span class='Comment'># Matches second header +</span>9 +</pre> diff --git a/docs/help/predicate.html b/docs/help/predicate.html new file mode 100644 index 00000000..fdd89394 --- /dev/null +++ b/docs/help/predicate.html @@ -0,0 +1,21 @@ +<head> + <link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/> + <link href="../style.css" rel="stylesheet"/> + <title>BQN: Question Mark (?)</title> +</head> +<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div> +<h1 id="question-mark-"><a class="header" href="#question-mark-">Question Mark (<code><span class='Head'>?</span></code>)</a></h1> +<h2 id="-predicate"><a class="header" href="#-predicate"><code><span class='Head'>?</span></code>: Predicate</a></h2> +<p><a class="fulldoc" href="../doc/block.html#predicates">→full documentation</a></p> +<p>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 <code><span class='Head'>?</span></code> stay if execution continues (1) but don't carry over to other bodies (0).</p> +<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=ezAgPyAzIDsgNH0KCk1pbiDihpAge/Cdlag88J2VqSA/IPCdlaggOyDwnZWpfQoKMyBNaW4gNQoKNCBNaW4gMg==">↗️</a><pre> <span class='Brace'>{</span><span class='Number'>0</span> <span class='Head'>?</span> <span class='Number'>3</span> <span class='Head'>;</span> <span class='Number'>4</span><span class='Brace'>}</span> +4 + + <span class='Function'>Min</span> <span class='Gets'>←</span> <span class='Brace'>{</span><span class='Value'>𝕨</span><span class='Function'><</span><span class='Value'>𝕩</span> <span class='Head'>?</span> <span class='Value'>𝕨</span> <span class='Head'>;</span> <span class='Value'>𝕩</span><span class='Brace'>}</span> + + <span class='Number'>3</span> <span class='Function'>Min</span> <span class='Number'>5</span> +3 + + <span class='Number'>4</span> <span class='Function'>Min</span> <span class='Number'>2</span> +2 +</pre> diff --git a/docs/repl.js b/docs/repl.js index bac0ca98..7eb55471 100644 --- a/docs/repl.js +++ b/docs/repl.js @@ -115,8 +115,8 @@ let typeChar = (t, c, ev) => { return false; } -let syncls={ v:"Value", f:"Function", m:"Modifier", d:"Modifier2", n:"Number", g:"Gets", p:"Paren", b:"Bracket", k:"Brace", l:"Ligature", n:"Nothing", s:"Separator", c:"Comment", a:"String" }; -let keydesc='f+Conjugate;Add_f-Negate;Subtract_f×Sign;Multiply_f÷Reciprocal;Divide_f⋆Exponential;Power_f√Square Root;Root_f⌊Floor;Minimum_f⌈Ceiling;Maximum_f∧Sort Up;And_f∨Sort Down;Or_f¬Not;Span_f|Absolute Value;Modulus_f≤Less Than or Equal to_f<Enclose;Less Than_f>Merge;Greater Than_f≥Greater Than or Equal to_f=Rank;Equals_f≠Length;Not Equals_f≡Depth;Match_f≢Shape;Not Match_f⊣Identity;Left_f⊢Identity;Right_f⥊Deshape;Reshape_f∾Join;Join to_f≍Solo;Couple_f⋈Enlist;Pair_f↑Prefixes;Take_f↓Suffixes;Drop_f↕Range;Windows_f«Shift Before_f»Shift After_f⌽Reverse;Rotate_f⍉Transpose;Reorder axes_f/Indices;Replicate_f⍋Grade Up;Bins Up_f⍒Grade Down;Bins Down_f⊏First Cell;Select_f⊑First;Pick_f⊐Classify;Index of_f⊒Occurrence Count;Progressive Index of_f∊Mark First;Member of_f⍷Deduplicate;Find_f⊔Group Indices;Group_f!Assert;Assert with message_m˙Constant_m˜Self/Swap_d∘Atop_d○Over_d⊸Before/Bind_d⟜After/Bind_d⌾Under_d⊘Valences_d◶Choose_d⎊Catch_d⎉Rank_m˘Cells_d⚇Depth_m¨Each_m⌜Table_d⍟Repeat_m⁼Undo_m´Fold_m˝Insert_m`Scan_g←Define_g⇐Export_g↩Change_s⋄Separator_s,Separator_v.Namespace field_p(Begin expression_p)End expression_k{Begin block_k}End block_b⟨Begin list_b⟩End list_l‿Strand_n·Nothing_v•System_v𝕨Left argument_f𝕎Left argument (as function)_v𝕩Right argument_f𝕏Right argument (as function)_v𝕗Modifier left operand (as subject)_f𝔽Modifier left operand_v𝕘2-modifier right operand (as subject)_f𝔾2-modifier right operand_v𝕤Current function (as subject)_f𝕊Current function_m𝕣Current modifier_n¯Minus_nπPi_n∞Infinity_a@Null character_c#Comment'.split(/[\n_]/); +let syncls={ v:"Value", f:"Function", m:"Modifier", d:"Modifier2", n:"Number", g:"Gets", p:"Paren", b:"Bracket", k:"Brace", h:"Head", l:"Ligature", n:"Nothing", s:"Separator", c:"Comment", a:"String" }; +let keydesc='f+Conjugate;Add_f-Negate;Subtract_f×Sign;Multiply_f÷Reciprocal;Divide_f⋆Exponential;Power_f√Square Root;Root_f⌊Floor;Minimum_f⌈Ceiling;Maximum_f∧Sort Up;And_f∨Sort Down;Or_f¬Not;Span_f|Absolute Value;Modulus_f≤Less Than or Equal to_f<Enclose;Less Than_f>Merge;Greater Than_f≥Greater Than or Equal to_f=Rank;Equals_f≠Length;Not Equals_f≡Depth;Match_f≢Shape;Not Match_f⊣Identity;Left_f⊢Identity;Right_f⥊Deshape;Reshape_f∾Join;Join to_f≍Solo;Couple_f⋈Enlist;Pair_f↑Prefixes;Take_f↓Suffixes;Drop_f↕Range;Windows_f«Shift Before_f»Shift After_f⌽Reverse;Rotate_f⍉Transpose;Reorder axes_f/Indices;Replicate_f⍋Grade Up;Bins Up_f⍒Grade Down;Bins Down_f⊏First Cell;Select_f⊑First;Pick_f⊐Classify;Index of_f⊒Occurrence Count;Progressive Index of_f∊Mark First;Member of_f⍷Deduplicate;Find_f⊔Group Indices;Group_f!Assert;Assert with message_m˙Constant_m˜Self/Swap_d∘Atop_d○Over_d⊸Before/Bind_d⟜After/Bind_d⌾Under_d⊘Valences_d◶Choose_d⎊Catch_d⎉Rank_m˘Cells_d⚇Depth_m¨Each_m⌜Table_d⍟Repeat_m⁼Undo_m´Fold_m˝Insert_m`Scan_g←Define_g⇐Export_g↩Change_s⋄Separator_s,Separator_v.Namespace field_p(Begin expression_p)End expression_k{Begin block_k}End block_h;Next body_h:Header_h?Predicate_b⟨Begin list_b⟩End list_l‿Strand_n·Nothing_v•System_v𝕨Left argument_f𝕎Left argument (as function)_v𝕩Right argument_f𝕏Right argument (as function)_v𝕗Modifier left operand (as subject)_f𝔽Modifier left operand_v𝕘2-modifier right operand (as subject)_f𝔾2-modifier right operand_v𝕤Current function (as subject)_f𝕊Current function_m𝕣Current modifier_n¯Minus_nπPi_n∞Infinity_a@Null character_c#Comment'.split(/[\n_]/); let kk=Array.from('`123456890-=~!@#$%^&*()_+qwertuiop[]QWERTIOP{}asdfghjkl;ASFGHKL:"zxcvbm,./ZXVBM<>? \''); let kv=Array.from('˜˘¨⁼⌜´˝∞¯•÷׬⎉⚇⍟◶⊘⎊⍎⍕⟨⟩√⋆⌽𝕨∊↑∧⊔⊏⊐π←→↙𝕎⍷𝕣⍋⊑⊒⍳⊣⊢⍉𝕤↕𝕗𝕘⊸∘○⟜⋄↖𝕊𝔽𝔾«⌾»·˙⥊𝕩↓∨⌊≡∾≍≠⋈𝕏⍒⌈≢≤≥⇐‿↩'); let keys={}, revkeys={}, primhelp={}, helpurl={}; 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 |
