From eb8e63d3a97f99b8a3da0573fc585953ef441314 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 16 Oct 2020 14:21:28 -0400 Subject: Another evaluation diagram --- docs/tutorial/expression.html | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'docs/tutorial') diff --git a/docs/tutorial/expression.html b/docs/tutorial/expression.html index 1f14e90b..7669df1a 100644 --- a/docs/tutorial/expression.html +++ b/docs/tutorial/expression.html @@ -112,6 +112,56 @@ ↗️
    (3 + 2×√2) - 1+√2
 0
 
+

That's a fairly large expression, so here's another evaluation diagram to check your understanding.

+ + + + (3 + 2×√2) - 1+√2 + + + + + + + + + + + + + + + + 3 + + + 2 + × + + 2 + - + 1 + + + + 2 + + + + 3 + + + 2 + × + + 2 + - + 1 + + + + 2 + + + + +

But wait: how do we know that in the expressions above uses the one-argument form? Remember that it can also take a left argument. For that matter, how do we know that - takes two arguments and not just one? Maybe this looks trivial now that we are just doing arithmetic, and a good enough answer for right now is that a function is called with one argument if there is nothing to its left, or another function, and with two arguments otherwise. But it gets more complicated as we expand the syntax with expressions that can return functions and so on, so it's never to early to start looking at a more rigorous viewpoint. In BQN, the way expressions are evaluated—the sequence of function calls and other operations—is determined by the syntactic role of the things it contains. A few rules of roles make sense of what's seen so far: