From 887bd8588f86b6014b961e236aaa36d31e775d9a Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 28 Apr 2022 08:18:39 -0400 Subject: More comments on Under --- docs/doc/under.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'docs/doc/under.html') diff --git a/docs/doc/under.html b/docs/doc/under.html index 58c9f9d4..ae931d47 100644 --- a/docs/doc/under.html +++ b/docs/doc/under.html @@ -65,6 +65,16 @@ ↗️
    (⊢↑˜≠÷2˙) "abcdef"
 "cbadef"
 
+

But you can't use a computation that uses array values, such as 10+((<5)/) to add 10 to each element below 5. This is because Under can change the array values, so that the function 𝔾 doesn't select the same elements before and after applying it (at the same time, Under can't change array structure, or at least not the parts that matter to 𝔾). To use a dynamic selection function, compute the mask or indices based on a copy of the argument and use those as part of 𝔾.

+↗️
    {10+((𝕩<5)/)𝕩} 38226
+⟨ 13 8 12 12 6 ⟩
+
+    (<5)/ 38226
+⟨ 3 2 2 ⟩
+
+    (<5)/ {10+((𝕩<5)/)𝕩} 38226
+⟨⟩
+

Under is useful with scans, as discussed in a section on reverse scan. In this case, is exactly invertible, so can just as easily be seen as computational Under. When 𝔾 has an exact inverse, there can only be one solution to the constraint on Under, and both forms must be the same.

↗️
    ` 1010111
 ⟨ 0 0 0 0 1 1 1 ⟩
@@ -74,7 +84,7 @@
 ↗️
    (+´÷≠)(ט) 2345
 3.674234614174767
 
-

This average is the square root of the average of the squares of the arguments, and lets us combine the two square-y steps. Similarly, ÷ can be used for a harmonic sum or mean (you might notice that computational Under is a lot more mathy than the structural one).

+

This average is the square root of the average of the squares of the arguments, and lets us combine the two square-y steps. Here there are two possible solutions because ¯3.67 has the same square as the positive result; BQN of course uses the principal root. Similarly, ÷ can be used for a harmonic sum or mean (you might notice that computational Under is a lot more mathy than the structural one).

Under is the idiomatic way to do a round-to-nearest function:

↗️
    (10×) 3.5246.7992.031
 ⟨ 3.5 6.7 2 ⟩
-- 
cgit v1.2.3