aboutsummaryrefslogtreecommitdiff
path: root/docs/doc
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-10-09 22:11:22 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-10-09 22:11:22 -0400
commit0ebe9ea698213413f2652ab587e3953e0206b356 (patch)
treefed1e5f69f87ffa4f2c3a4423fc791f37b7a6481 /docs/doc
parentafc086a54b9f37acd4d90ff6cc607ab3008c78f9 (diff)
Point out use of immediate block with predicates
Diffstat (limited to 'docs/doc')
-rw-r--r--docs/doc/block.html2
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/doc/block.html b/docs/doc/block.html
index 9ae75ef7..72aaecfd 100644
--- a/docs/doc/block.html
+++ b/docs/doc/block.html
@@ -228,7 +228,7 @@ ERROR
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=eyBy4oaQ4oy98J2VqSDii4QgJ3QnPeKKkXIgPyByIDsg8J2VqSB9wqggInRlc3Qi4oC/InRoaXMi">↗️</a><pre> <span class='Brace'>{</span> <span class='Value'>r</span><span class='Gets'>←</span><span class='Function'>⌽</span><span class='Value'>𝕩</span> <span class='Separator'>β‹„</span> <span class='String'>'t'</span><span class='Function'>=βŠ‘</span><span class='Value'>r</span> <span class='Value'>?</span> <span class='Value'>r</span> <span class='Value'>;</span> <span class='Value'>𝕩</span> <span class='Brace'>}</span><span class='Modifier'>Β¨</span> <span class='String'>&quot;test&quot;</span><span class='Ligature'>β€Ώ</span><span class='String'>&quot;this&quot;</span>
⟨ "tset" "this" ⟩
</pre>
-<p>So <code><span class='Value'>r</span></code> is the reversed argument, and if its first character (the last one in <code><span class='Value'>𝕩</span></code>) is <code><span class='String'>'t'</span></code> then it returns <code><span class='Value'>r</span></code>, and otherwise we abandon that line of reasoning and return <code><span class='Value'>𝕩</span></code>. This sounds a lot like an if statement. And <code><span class='Brace'>{</span> <span class='Value'>a</span><span class='Function'>&lt;</span><span class='Value'>b</span> <span class='Value'>?</span> <span class='Value'>a</span> <span class='Value'>;</span> <span class='Value'>b</span> <span class='Brace'>}</span></code>, which computes <code><span class='Value'>a</span><span class='Function'>⌊</span><span class='Value'>b</span></code> the hard way, shows how the syntax can be similar to a ternary operator. But <code><span class='Value'>?;</span></code> is more flexible than that. It can support any number of options, with multiple tests for each oneβ€”the structure below is &quot;if _ and _ then _; else if _ then _; else _&quot;.</p>
+<p>So <code><span class='Value'>r</span></code> is the reversed argument, and if its first character (the last one in <code><span class='Value'>𝕩</span></code>) is <code><span class='String'>'t'</span></code> then it returns <code><span class='Value'>r</span></code>, and otherwise we abandon that line of reasoning and return <code><span class='Value'>𝕩</span></code>. This sounds a lot like an if statement. And <code><span class='Brace'>{</span> <span class='Value'>a</span><span class='Function'>&lt;</span><span class='Value'>b</span> <span class='Value'>?</span> <span class='Value'>a</span> <span class='Value'>;</span> <span class='Value'>b</span> <span class='Brace'>}</span></code>, which computes <code><span class='Value'>a</span><span class='Function'>⌊</span><span class='Value'>b</span></code> the hard way, shows how the syntax can be similar to a ternary operator. This is an immediate block with multiple bodies, something that makes sense with predicates but not headers. But <code><span class='Value'>?;</span></code> offers more possibilities. It can support any number of options, with multiple tests for each oneβ€”the structure below is &quot;if _ and _ then _; else if _ then _; else _&quot;.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=VGhpbmcg4oaQIHsg8J2VqeKJpTM/IPCdlaniiaQ4PyAyfPCdlakgOyDwnZWpPTA/IEAgOyDiiJ4gfQoKKOKKoiDiiY0gVGhpbmfCqCkg4oaVMTAgICMgVGFibGUgb2YgYXJndW1lbnRzIGFuZCByZXN1bHRz">↗️</a><pre> <span class='Function'>Thing</span> <span class='Gets'>←</span> <span class='Brace'>{</span> <span class='Value'>𝕩</span><span class='Function'>β‰₯</span><span class='Number'>3</span><span class='Value'>?</span> <span class='Value'>𝕩</span><span class='Function'>≀</span><span class='Number'>8</span><span class='Value'>?</span> <span class='Number'>2</span><span class='Function'>|</span><span class='Value'>𝕩</span> <span class='Value'>;</span> <span class='Value'>𝕩</span><span class='Function'>=</span><span class='Number'>0</span><span class='Value'>?</span> <span class='String'>@</span> <span class='Value'>;</span> <span class='Number'>∞</span> <span class='Brace'>}</span>
<span class='Paren'>(</span><span class='Function'>⊒</span> <span class='Function'>≍</span> <span class='Function'>Thing</span><span class='Modifier'>Β¨</span><span class='Paren'>)</span> <span class='Function'>↕</span><span class='Number'>10</span> <span class='Comment'># Table of arguments and results