From 7c24767d82a01f23e1c4010f1a9d0c02f2befc5f Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 4 Jan 2022 22:03:22 -0500 Subject: =?UTF-8?q?Switch=20from=20using=20=E2=89=8D=20to=20=E2=8B=88=20in?= =?UTF-8?q?=20the=20tutorials=20so=20far?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/tutorial/variable.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/tutorial/variable.html') diff --git a/docs/tutorial/variable.html b/docs/tutorial/variable.html index 226b54ae..634bd5d5 100644 --- a/docs/tutorial/variable.html +++ b/docs/tutorial/variable.html @@ -14,13 +14,13 @@

Like that.

Defining variables

BQN uses the left-pointing arrow to define variables, as shown above. Most of the time it's best to use it in a plain way, with just the name and its definition, but it's also possible to define multiple variables using list notation, or to define a variable as part of a larger expression that continues to the left (in terms of precedence, behaves like a function, but it isn't one—it's a part of syntax).

-↗️
    pieten   π, 1, 10 
+↗️
    pieten   π, 1, 10 
 ⟨ 3.141592653589793 2.718281828459045 10 ⟩
 
     ten × pi
 31.41592653589793
 
-    three  ten - three  3
+    three  ten - three  3
 ⟨ 3 7 ⟩
 

A variable can't be defined twice in the same scope. Later we'll work with functions and other pieces of code that create their own scopes, but for now all you need to know is that all the code in a tutorial runs in the same scope. So three is already defined, and can't be defined again.

@@ -194,7 +194,7 @@ ERROR

Well, the function Pick () isn't doing anything too special here: the left argument is an index and it picks the element at that index from the right argument (which has to be a list, although there's a more complicated case with a compound left argument that we won't talk about now). Elements of a list are numbered starting at 0. This matches with the Range () function we saw earlier, in that the value of Range's result at a particular index is equal to that index. As an illustration, we can pair up each element of a list with its index by calling Range on the list's length.

-↗️
    (3) ¨ "BQN"
+↗️
    (3) ¨ "BQN"
 ⟨ ⟨ 0 'B' ⟩ ⟨ 1 'Q' ⟩ ⟨ 2 'N' ⟩ ⟩
 
     1  "BQN"
-- 
cgit v1.2.3