aboutsummaryrefslogtreecommitdiff
path: root/docs/doc/logic.html
diff options
context:
space:
mode:
authoralexdikelsky <alexander.dikelsky@gmail.com>2021-09-24 07:54:23 -0500
committeralexdikelsky <alexander.dikelsky@gmail.com>2021-09-24 07:54:23 -0500
commit89ffbec6ac981a81b9e78e6555124f51fdd78df2 (patch)
tree3b00b817698fdfa196e0eaad75cee93991fa8d7e /docs/doc/logic.html
parent24a1c75dec5746acb75949b8f41d8044fe98040c (diff)
Add reference implementations for gcd and lcm to logic.md
Diffstat (limited to 'docs/doc/logic.html')
-rw-r--r--docs/doc/logic.html2
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/doc/logic.html b/docs/doc/logic.html
index 8fc23c44..6df8a5fc 100644
--- a/docs/doc/logic.html
+++ b/docs/doc/logic.html
@@ -39,7 +39,7 @@
</pre>
<p>As with logical And and Or, any value and 0 is 0, while any value or 1 is 1. The other boolean values give the identity values for the two functions: 1 and any value gives that value, as does 0 or the value.</p>
<h2 id="why-not-gcd-and-lcm"><a class="header" href="#why-not-gcd-and-lcm">Why not GCD and LCM?</a></h2>
-<p>The main reason for omitting these functions is that they are complicated and, when applied to real or complex numbers, require a significant number of design decisions where there is no obvious choice (for example, whether to use comparison tolerance). On the other hand, these functions are fairly easy to implement, which allows the programmer to control the details, and also add functionality such as the extended GCD.</p>
+<p>The main reason for omitting these functions is that they are complicated and, when applied to real or complex numbers, require a significant number of design decisions where there is no obvious choice (for example, whether to use comparison tolerance). On the other hand, these functions are fairly easy to implement (reference implementations for <a href="https://mlochbaum.github.io/bqncrate/?q=gcd">gcd</a> and <a href="https://mlochbaum.github.io/bqncrate/?q=lcm">lcm</a> on <a href="https://mlochbaum.github.io/bqncrate">bqncrate</a>), which allows the programmer to control the details, and also add functionality such as the extended GCD.</p>
<p>A secondary reason is that the GCD falls short as an extension of Or, because its identity value 0 is not total. <code><span class='Number'>0</span><span class='Function'>∨</span><span class='Value'>x</span></code>, for a real number <code><span class='Value'>x</span></code>, is actually equal to <code><span class='Function'>|</span><span class='Value'>x</span></code> and not <code><span class='Value'>x</span></code>: for example, <code><span class='Number'>0</span><span class='Function'>∨</span><span class='Number'>¯2</span></code> is <code><span class='Number'>2</span></code> in APL. This means the identity <code><span class='Number'>0</span><span class='Function'>∨</span><span class='Value'>x</span> <span class='Gets'>←→</span> <span class='Value'>x</span></code> isn't reliable in APL.</p>
<h2 id="identity-values"><a class="header" href="#identity-values">Identity values</a></h2>
<p>It's common to apply a <a href="fold.html">fold</a> <code><span class='Function'>∧</span><span class='Modifier'>´</span></code> or <code><span class='Function'>∨</span><span class='Modifier'>´</span></code> to a list (checking whether all elements are true and whether any are true, respectively), and so it's important for extensions to And and Or to share their <a href="fold.html#identity-values">identity</a> value. <a href="arithmetic.html#additional-arithmetic">Minimum and Maximum</a> do match And and Or when restricted to booleans, but they have different identity values. It would be dangerous to use Maximum to check whether any element of a list is true because <code><span class='Function'>⌈</span><span class='Modifier'>´</span><span class='Bracket'>⟨⟩</span></code> yields <code><span class='Number'>¯∞</span></code> instead of <code><span class='Number'>0</span></code>—a bug waiting to happen. To avoid this the programmer would have to use an initial value <code><span class='Value'>𝕨</span></code> of <code><span class='Number'>0</span></code>, which is easy to forget.</p>