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 --- tutorial/list.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'tutorial/list.md') diff --git a/tutorial/list.md b/tutorial/list.md index bd8071a6..b34587ca 100644 --- a/tutorial/list.md +++ b/tutorial/list.md @@ -41,7 +41,7 @@ The two characters `,` and `⋄` are completely interchangeable, and newline is -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‿+‿- @@ -90,7 +90,7 @@ FS ← {𝕩 Enc˜ "g"Attr⟨"font-size",(Fmt𝕨)∾"px"⟩} ⟩ --> -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 @@ -140,6 +140,7 @@ Reverse (`⌽`) puts the list back to front. 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⟩ + ¯1 ⌽ "bcdea" ### …and modifiers @@ -147,7 +148,7 @@ With a left argument `⌽` means Rotate instead, and shifts values over by the s -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" @@ -167,7 +168,7 @@ To match the order of BQN evaluation, Fold moves over its argument array from ri 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: @@ -179,7 +180,7 @@ But you shouldn't! Just `∾` will do the job for you—with no left argument it ## 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?