From a913a084a5750350a5ef888a61fabcad9ceedabe Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 21 Sep 2020 19:33:56 -0400 Subject: Small fixes in expressions tutorial --- docs/tutorial/expression.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'docs/tutorial') diff --git a/docs/tutorial/expression.html b/docs/tutorial/expression.html index a0b3b3e5..a3e8e3f0 100644 --- a/docs/tutorial/expression.html +++ b/docs/tutorial/expression.html @@ -24,7 +24,7 @@ ÷ 0 -

Okay, now BQN looks like normal (grade-school) mathematics, which is sort of like looking normal. Pi (π) represents that real famous number and Infinity () is part of the number system (the BQN spec allows an implementation to choose its number system, and all existing implementations use double-precision floats, like Javascript or Lua). In analogy with the one-argument form of Minus (-) giving the negation of a number, Divide (÷) with only one argument gives its reciprocal.

+

Okay, now BQN looks like normal (grade-school) mathematics, which is sort of like looking normal. Pi (π) represents that real famous number and Infinity () is also part of the number system (the BQN spec allows an implementation to choose its number system, and all existing implementations use double-precision floats, like Javascript or Lua). In analogy with the one-argument form of Minus (-) giving the negation of a number, Divide (÷) with only one argument gives its reciprocal.

A number can be raised to the power of another with Power, written . That's a star rather than an asterisk; BQN doesn't use the asterisk symbol. If it's called without a left argument, then uses a base of Euler's number e and is called Exponential.

↗️
    2  3
 8
@@ -99,7 +99,8 @@
 

But as I blurted earlier, you can't add two characters (and no you can never concatenate things by adding them). It's also an error to negate a character or subtract it from a number. Characters reside in an [intimidating word for simple concept warning] affine space [no relation to those fancy Rust things called linear and affine types], meaning that the following operations are allowed:

Other examples of affine spaces are

@@ -109,8 +110,8 @@
  • Pointers in a computer's memory. I'll let you verify for yourself that the rules are the same.
  • Want to shift an uppercase character to lowercase? Affine characters to the rescue:

    -↗️
        'K' + 'A'-'a'
    -'+'
    +↗️
        'K' + 'a'-'A'
    +'k'
     

    Convert a character to a digit? Here you go:

    ↗️
        '4' - '0'
    @@ -123,7 +124,7 @@
     'a'
     

    It's a convenient way to write non-printing characters without having to include them in your source code: for example @+10 is the newline character.

    -

    Addition and subtraction with affine characters have all the same algebraic properties that they do with numbers. One way to see this is to think of values as a combination of "characterness" (0 for numbers and 1 for characters) and either numeric value or code point. Addition and subtraction are done element-wise on these pairs of numbers, and are allowed if the result is a valid value, that is, its characterness is 0 or 1 and its value is a valid code point if the characterness is 1. However, because the space of values is no longer closed under addition and subtraction, certain rearrangements of valid computations might not be valid, because one of the values produced in the middle isn't legal.

    +

    Addition and subtraction with affine characters have all the same algebraic properties that they do with numbers. One way to see this is to think of values as a combination of "characterness" (0 for numbers and 1 for characters) and either numeric value or code point. Addition and subtraction are done element-wise on these pairs of numbers, and are allowed if the result is a valid value, that is, its characterness is 0 or 1 and its value is a valid code point if the characterness is 1. However, because the space of values is no longer closed under addition and subtraction, certain rearrangements of valid computations might not be valid, if one of the values produced in the middle isn't legal.

    Modifiers

    Functions are nice and all, but to really bring us into the space age BQN has a second level of function called modifiers (the space age in this case is when operators were introduced to APL in the early 60s—hey, did you know the second APL conference was held at Goddard Space Flight Center?). While functions apply to subjects, modifiers can apply to functions or subjects, and return functions. For example, the 1-modifier ˜ modifies one function by swapping the arguments before calling it (Swap), or copying the right argument to the left if there's only one (Self).

    ↗️
        2 -˜ 'd'  # Subtract from
    -- 
    cgit v1.2.3