From 1045ede124fc60de41f273d7997521d386c82bf1 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 24 Jul 2022 16:04:24 -0400 Subject: Editing pass over first two tutorials --- docs/tutorial/list.html | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'docs/tutorial/list.html') diff --git a/docs/tutorial/list.html b/docs/tutorial/list.html index 6b423da0..2d0e9be9 100644 --- a/docs/tutorial/list.html +++ b/docs/tutorial/list.html @@ -73,7 +73,7 @@ -

Finally, strand notation is a shortcut for simple lists, like one that just lists a few numbers. It's written with the ligature , which has a higher precedence than either functions or operators (and on the BQN keyboard, the ligature is written with a backslash, then a space). A sequence of values joined with ligatures becomes a list, so that for example the following two expressions are equivalent:

+

Finally, strand notation is a shortcut for simple lists, like one that just lists a few numbers. It's written with the ligature , which has a higher precedence than either functions or operators (and is typed with backslash-space on the BQN keyboard). A sequence of values joined with ligatures becomes a list, so that for example the following two expressions are equivalent:

2,+,-
 2+-
 
@@ -113,7 +113,7 @@ -

Lists are just one-dimensional arrays. Types are divided into data types, which tend to have a subject role, and operation types, which tend to have a role matching their type. Also, any value that's not an array, such as everything we used in the last tutorial, is called an atom.

+

Lists are just one-dimensional arrays. These types are divided into data types, which correspond to a subject role, and operation types, which each have a matching role. Also, any value that's not an array, such as everything we used in the last tutorial, is called an atom.

Arithmetic on lists

Arithmetic functions automatically apply to each element of a list argument. If both arguments are lists, they have to have the same length, and they're matched up one element at a time.

↗️
    ÷ 2,3,4
@@ -181,8 +181,9 @@
 "reward"
 

With a left argument means Rotate instead, and shifts values over by the specified amount, wrapping those that go off the end to the other side. A positive value rotates to the left, and a negative one rotates right.

-↗️
    2  0,1,2,3,4
+↗️
    2  0,1,2,3,4
 ⟨ 2 3 4 0 1 ⟩
+
     ¯1  "bcdea"
 "abcde"
 
@@ -206,7 +207,7 @@ -

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.

+

The 1-modifier Each (¨) applies its operand to every element of a list argument, like map in a functional programming language. With two list arguments, Each pairs the corresponding elements like arithmetic does, or a bit like a zip function (unlike arithmetic, it only goes one level deep). If one argument is a list and one's an atom, the atom is reused every time instead.

↗️
    ¨ "abcd""ABCDEF""01"
 ⟨ "dcba" "FEDCBA" "10" ⟩
 
@@ -229,7 +230,7 @@
 3
 

With this evaluation order, -´ gives the alternating sum of its argument. Think of it this way: the left argument of each - is a single number, while the right argument is made up of all the numbers to the right subtracted together. So each - flips the sign of every number to its right, and every number is negated by all the -s to its left. The first number (1 above) never gets negated, the second is negated once, the third is negated twice, returning it to its original value… the signs alternate.

-

Hey, isn't it dissonant that the first, second, and third numbers are negated zero, one, and two times? If they were the zeroth, first, and second it wouldn't be…

+

Hey, isn't it dissonant that the first, second, and third numbers are negated zero, one, and two times? Not if you call them the zeroth, first, and second…

You can fold with the Join To function to join several lists together:

↗️
    ´  "con", "cat", "enat", "e" 
 "concatenate"
@@ -239,7 +240,7 @@
 "concatenate"
 

Example: base decoding

-

Some people like to imagine that robots or other techno-beings speak entirely in binary-encoded ASCII, like for instance "01001110 01100101 01110010 01100100 00100001". This is dumb for a lot of reasons, and the encoded text probably just says something inane, but you're a slave to curiosity and can't ignore it. Are one and a half tutorials of BQN enough to clear your conscience?

+

Some people like to imagine that robots or other techno-beings speak entirely in binary-encoded ASCII, like for instance "01001110 01100101 01110010 01100100 00100001". This is dumb for a lot of reasons, and the encoded text probably just says something inane, but you're a slave to curiosity and can't ignore it. Are one and two-thirds tutorials of BQN enough to clear your conscience?

@@ -259,7 +260,7 @@ ↗️
     8
 ⟨ 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:

+

Natural numbers in BQN start at 0. I'll get to the second primitive 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
 ⟨ ⟨ 8 1 ⟩ ⟨ 4 0 ⟩ ⟨ 2 0 ⟩ ⟨ 1 1 ⟩ ⟩
 
@@ -363,7 +364,7 @@ 9

Summary

-

There are three types of syntax that create lists: the "string literal" for lists of characters and either enclosing angle brackets ⟨⟩ with , or or newline characters or connecting ligatures for lists with arbitrary elements. The ligature has a higher precedence than functions or modifiers, so we should add it to our precedence table:

+

There are three types of syntax that create lists. "string literal" gives a list of characters. For arbitrary lists, use enclosing angle brackets ⟨⟩ with , or or newline between elements, or just connect elements with ligatures . The ligature has a higher precedence than functions or modifiers and might require parentheses, so we should add it to our precedence table:

@@ -395,8 +396,8 @@
-

The elements of a list can have any syntactic role; it's ignored and the list as a whole is a subject.

-

We introduced a few new primitives. The links below go to the full documentation pages for them.

+

The elements of a list can have any syntactic role. It's ignored and the list as a whole is a subject.

+

We introduced a few new primitives. The links in the table go to their full documentation pages.

@@ -438,5 +439,5 @@
-

Additionally, we saw that the arithmetic functions work naturally on lists, automatically applying to every element of a single list argument or pairing up the elements of two list arguments.

+

And we saw that the arithmetic functions work naturally on lists, automatically applying to every element of a single list argument or pairing up the elements of two list arguments.

Even this small amount of list functionality is enough to tackle some little problems. We haven't even introduced a function notation yet!

-- cgit v1.2.3