From daf62afe673613c8a90f5d9e494ede2ccaf7ef72 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 12 Nov 2021 22:16:50 -0500 Subject: Re-generate some docs --- docs/tutorial/combinator.html | 6 +++--- docs/tutorial/expression.html | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/tutorial') diff --git a/docs/tutorial/combinator.html b/docs/tutorial/combinator.html index a9cd7627..abfcfbe0 100644 --- a/docs/tutorial/combinator.html +++ b/docs/tutorial/combinator.html @@ -536,7 +536,7 @@ ↗️
    ÷ 8
 ⟨ 0 0.125 0.25 0.375 0.5 0.625 0.75 0.875 ⟩
     (8) ÷ 7
-⟨ 0 0.14285714285714285 0.2857142857142857 0.42857142857142855 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩
+⟨ 0 0.1428571428571428 0.2857142857142857 0.4285714285714285 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩
 

What function turns 8 into 7? We can bind 1 to - on the left:

↗️
    -1 8
@@ -544,11 +544,11 @@
 

Now we need to apply and this function to 8, dividing the results. It turns out we can do this using both Before and After. On one side we'll have 8, and on the other -1 8.

↗️
    ÷(-1) 8
-⟨ 0 0.14285714285714285 0.2857142857142857 0.42857142857142855 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩
+⟨ 0 0.1428571428571428 0.2857142857142857 0.4285714285714285 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩
 

This structure—Before on the left, After on the right—is also useful with two arguments: I call it "split compose", and it applies one function to the left argument and another to the right before passing them both to the middle function (if the functions on both sides are the same, that would be Over!). Although it turns out it's not needed in the one-argument case. You'll get the same result just by jamming the functions together. This is called a "train" and we should probably leave it for another tutorial before going too far off the rails.

↗️
    (↕÷-1) 8
-⟨ 0 0.14285714285714285 0.2857142857142857 0.42857142857142855 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩
+⟨ 0 0.1428571428571428 0.2857142857142857 0.4285714285714285 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩
 

Base decoding continued

We're speeding up a bit now, so in the examples below it might take some time for you to break down what I did and why. Remember that you can open any expression in the REPL in order to change parts of it or view the syntax. And don't get discouraged just because of how long it takes to understand a line of code! First, you'll surely get faster in fitting the pieces together. Second, a line of BQN often has more code in it than a line in other languages, because primitives have such short names. Think about how much functionality you can read and understand rather than how few lines you get through.

diff --git a/docs/tutorial/expression.html b/docs/tutorial/expression.html index 89a43380..bfcdc6f7 100644 --- a/docs/tutorial/expression.html +++ b/docs/tutorial/expression.html @@ -92,7 +92,7 @@

You could use Power to take square roots and n-th roots, but BQN has a primitive for this purpose. If no left argument is provided, then it's the Square Root function; with a left argument it's called Root, and raises the right argument to the power of one divided by the left argument.

↗️
     2
-1.4142135623730951
+1.414213562373095
     3  27
 3
 
@@ -112,7 +112,7 @@

I bet if you try hard you'll remember how much you hated learning to do exponentiation before multiplication and division before addition and subtraction. Didn't I tell you Earth was a confusing place? BQN treats all functions—not only primitives, but also the ones you define—the same way. They're evaluated from right to left, and parentheses form subexpressions that are evaluated entirely before they can be used.

For a longer example, here's an expression for the volume of a sphere with radius 2.

↗️
    (4÷3) × π × 23
-33.510321638291124
+33.51032163829112
 

The evaluation order is diagrammed below, with the function on the first line evaluated first, then × on the next, and so on. The effect of the parentheses is that ÷ is evaluated before the leftmost ×.

-- cgit v1.2.3