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/combinator.html | 6 +++--- docs/tutorial/expression.html | 2 +- docs/tutorial/index.html | 2 +- docs/tutorial/list.html | 36 +++++++++++++++++++----------------- docs/tutorial/variable.html | 6 +++--- 5 files changed, 27 insertions(+), 25 deletions(-) (limited to 'docs/tutorial') diff --git a/docs/tutorial/combinator.html b/docs/tutorial/combinator.html index abfcfbe0..65b223ab 100644 --- a/docs/tutorial/combinator.html +++ b/docs/tutorial/combinator.html @@ -304,10 +304,10 @@ ↗️
    "string" = "sting"
 0
 
-

Let's use the list formation function Solo/Couple () to see what happens more clearly:

-↗️
    "string"  "sting"
+

Let's use the list formation function Enlist/Pair () to see what happens more clearly:

+↗️
    "string"  "sting"
 ⟨ 6 5 ⟩
-     "sting"
+     "sting"
 ⟨ 5 ⟩
 

Atop always applies its right operand once, passing every argument (that is, one or two of them) in that call. Over calls its right operand on each argument individually. The results are then all used as arguments to the left operand. If there's only one argument, Atop and Over turn out to be the same: both of them call the right operand, then the left, like ordinary mathematical composition. Here are the two together for comparison.

diff --git a/docs/tutorial/expression.html b/docs/tutorial/expression.html index 98b4530d..ed446ae2 100644 --- a/docs/tutorial/expression.html +++ b/docs/tutorial/expression.html @@ -331,7 +331,7 @@ 3

Well, I guess it's not pedagogically useless, as it does demonstrate that a modifier can be applied to subjects as well as functions. Even though 3 is a subject, 3˙ is a function, and can be applied to and ignore the two arguments 2 and 4.

-

With three examples you may have noticed that 1-modifiers tend to cluster at the top of the screen. In fact, every primitive 1-modifer is a superscript character: we've covered ˜⁼˙, and the remaining array-based modifiers ˘¨⌜´˝` will show up later.

+

With three examples you may have noticed that 1-modifiers tend to cluster at the top of the line. In fact, every primitive 1-modifer is a superscript character: we've covered ˜⁼˙, and the remaining array-based modifiers ˘¨⌜´˝` will show up later.

2-modifiers

Made it to the last role, the 2-modifier (if you think something's been skipped, you're free to call subjects 0-modifiers. They don't modify anything. Just not when other people can hear you). To introduce them we'll use Atop , which composes two functions as in mathematics. The resulting function allows one or two arguments like any BQN function: these are all passed to the function on the right, and the result of that application is passed to the function on the left. So the function on the left is only ever called with one argument.

↗️
    3 ט+ 4  # Square of 3 plus 4
diff --git a/docs/tutorial/index.html b/docs/tutorial/index.html
index 85a2431f..ded09fb1 100644
--- a/docs/tutorial/index.html
+++ b/docs/tutorial/index.html
@@ -25,7 +25,7 @@
 
 List manipulation
 Lists, strings, and strands; pervasion
-∾≍⌽↕¨´
+∾⋈⌽↕¨´
 
 
 Combinators
diff --git a/docs/tutorial/list.html b/docs/tutorial/list.html
index 1f62233c..4df69829 100644
--- a/docs/tutorial/list.html
+++ b/docs/tutorial/list.html
@@ -78,11 +78,13 @@
 2+-
 

Strand notation is shorter and looks less cluttered in this example. As with lists, anything goes in a strand, but if it's the result of a function or operator, or another strand, then it has to be put in parentheses first. With one set of parentheses, a strand will be just as long as the equivalent bracketed list, and with two you're better off using the list.

-

An individual ligature part of BQN syntax, not a value, and it doesn't do something specific like a function does. It's the sequence of ligatures that makes whatever they join together into a list. So if we parenthesize either ligature below, we get a different result! Ligatures aren't right-associative or left-associative.

-↗️
    012
+

An individual ligature is part of BQN syntax, not a value, and it doesn't do something specific like a function does. It's the sequence of ligatures that makes whatever they join together into a list. So if we parenthesize either ligature below, we get a different result! Ligatures aren't right-associative or left-associative.

+↗️
    012
 ⟨ 0 1 2 ⟩
+
     (01)2
 ⟨ ⟨ 0 1 ⟩ 2 ⟩
+
     0(12)
 ⟨ 0 ⟨ 1 2 ⟩ ⟩
 
@@ -136,10 +138,10 @@

Some list functions

- + - - + + @@ -156,11 +158,11 @@
\.SoloCoupleEnlistPair

Let's introduce a few primitives to work with lists.

-

Make one or two atom arguments into a list with , pronounced Solo in the one-argument case and Couple in the two-argument case. This might not seem to merit a symbol but there's more to come. Don't call it on lists and ponder the results, igniting a hunger for ever more dimensions.

-↗️
     4
-⟨ 4 ⟩
+

Make one or two arguments into a list with , pronounced Enlist in the one-argument case and Pair in the two-argument case. This is kind of the same thing as list notation, and in fact I'd write the two examples below as list literals. But BQN is set up to get the most out of functions, so it's very useful to have a function version of that special syntax for lists built in.

+↗️
     "elt"
+⟨ "elt" ⟩
 
-    2  4
+    2  4
 ⟨ 2 4 ⟩
 

Concatenate lists with Join To (). The little chain link symbol—technically "inverted lazy S"—is my favorite in BQN. Hook those lists together!

@@ -173,7 +175,7 @@ "plural" 's' "plurals"
-

The last two examples show that you can join a list to an atom, making it the first or last element of the result. This is a little suspect because if you decide the data being stored is more complicated and start using a list instead of an atom, then it will no longer be used as a single element but rather a subsection of the result. So I would only use that shortcut for something like a numeric literal that's clearly an atom and will stay that way, and otherwise wrap those atomic arguments in some ⟨⟩ brackets. Join will even work with two atoms, but in that case I'd say it makes more sense to use Couple instead.

+

The last two examples show that you can join a list to an atom, making it the first or last element of the result. This is a little suspect because if you decide the data being stored is more complicated and start using a list instead of an atom, then it will no longer be used as a single element but rather a subsection of the result. So I would only use that shortcut for something like a numeric literal that's clearly an atom and will stay that way, and otherwise wrap those atomic arguments in some ⟨⟩ brackets. Join will even work with two atoms, but in that case it makes more sense to use Pair instead.

Reverse () puts the list back to front.

↗️
     "drawer"
 "reward"
@@ -205,13 +207,13 @@
 
 
 

The 1-modifier Each (¨) applies its operand to every element of a list argument: it's the same as map in a functional programming language. With two list arguments (which have to have the same length), Each pairs the corresponding elements from each, a bit like a zip function. If one argument is a list and one's an atom, the atom is reused every time instead.

-↗️
    ¨ "abcd""ABCDEF""01"
+↗️
    ¨ "abcd""ABCDEF""01"
 ⟨ "dcba" "FEDCBA" "10" ⟩
 
     "string""list""array" ¨ 's'
 ⟨ "strings" "lists" "arrays" ⟩
 
-    "abc" ¨  "abc"
+    "abc" ¨  "abc"
 ⟨ "ac" "bb" "ca" ⟩
 

Fold (´) is the higher-order function also known as reduce or accumulate. It applies its operand function between each pair of elements in a list argument. For example, +´ gives the sum of a list and ×´ gives its product.

@@ -232,7 +234,7 @@ ↗️
    ´  "con", "cat", "enat", "e" 
 "concatenate"
 
-

But you shouldn't! Just will do the job for you—with no left argument it's just called "Join" (it's like Javascript's .join(), but with no separator and not specific to strings). And it could do more jobs if you had more dimensions. But I'm sure that's the furthest thing from your mind.

+

But you shouldn't! Just will do the job for you—with no left argument it's just called "Join" (it's like Javascript's .join(), but with no separator and not specific to strings). And it could do more jobs if you had more dimensions. But let's not push it.

↗️
      "con", "cat", "enat", "e" 
 "concatenate"
 
@@ -258,7 +260,7 @@ ⟨ 0 1 2 3 4 5 6 7 ⟩

Natural numbers in BQN start at 0. I'll get to the second function in a moment, but first let's consider how we'd decode just one number in binary. I'll pick a smaller one: 9 is 1001 in binary. Like the first 1 in decimal 1001 counts for one thousand or 103, the first one in binary 1001 counts for 8, which is 23. We can put each number next to its place value like this:

-↗️
    8421 ¨ 1001
+↗️
    8421 ¨ 1001
 ⟨ ⟨ 8 1 ⟩ ⟨ 4 0 ⟩ ⟨ 2 0 ⟩ ⟨ 1 1 ⟩ ⟩
 

To get the value we multiply each number by its place value and then add them up.

@@ -410,9 +412,9 @@ ERROR Join To - -Solo -Couple + +Enlist +Pair 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