From 60d51c85dd306989e919e91e37d9b94fe60411c2 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 22 Aug 2020 09:47:16 -0400 Subject: Add REPL links to documentation code blocks --- docs/doc/syntax.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/doc/syntax.html') diff --git a/docs/doc/syntax.html b/docs/doc/syntax.html index 78e708b0..d1cb06ac 100644 --- a/docs/doc/syntax.html +++ b/docs/doc/syntax.html @@ -95,11 +95,11 @@

Constants

BQN has single-token notation for numbers, strings, and characters.

Numbers allow the typical decimal notation with ¯ for the negative sign (because - is a function) and e for scientific notation (or E, as numeric notation is case-insensitive). and π may be used as special numeric values. If complex numbers are supported, then they can be written with the components separated by i. However, no BQN to date supports complex numbers.

-
     ¯π  0.5  5e¯1  1.5E3      # A list of numbers
+↗️
     ¯π  0.5  5e¯1  1.5E3      # A list of numbers
 ⟨ ¯3.14159265358979 0.5 0.5 1500 ∞ ⟩
 

Strings are written with double quotes "", and characters with single quotes '' with a single character in between. A double quote within a string can be escaped by writing it twice; if two string literals are next to each other, they must be separated by a space. In contrast, character literals do not use escapes, as the length is already known.

-
    ¨  "str"  "s't""r"  'c'  '''  '"'    # "" is an escape
+↗️
    ¨  "str"  "s't""r"  'c'  '''  '"'    # "" is an escape
 ⟨ 3 5 1 1 1 ⟩
 
     ¨  "a"  'a'    # A string is an array but a character isn't
@@ -116,7 +116,7 @@
 
 

These roles work exactly like they do in APL, with functions applying to one or two subject arguments, 1-modifiers taking a single function or subject on the left, and 2-modifiers taking a function or subject on each side.

Unlike APL, in BQN the syntactic role of an identifier is determined purely by the way it's spelled: a lowercase first letter (name) makes it a subject, an uppercase first letter (Name) makes it a function, and underscores are used for 1-modifiers (_name) and 2-modifiers (_name_). Below, the function {𝕎𝕩} treats its left argument 𝕎 as a function and its right argument 𝕩 as a subject. With a list of functions, we can make a table of the square and square root of a few numbers:

-
    ט, {𝕎𝕩} 149
+↗️
    ט, {𝕎𝕩} 149
 ┌─         
 ╵ 1 16 81  
   1  2  3  
@@ -125,13 +125,13 @@
 

BQN's built-in operations also have patterns to indicate the syntactic role: 1-modifiers (˜¨˘⁼⌜´`) are all superscript characters, and 2-modifiers (∘○⊸⟜⌾⊘◶⚇⎉⍟) all have an unbroken circle (two functions ⌽⍉ have broken circles with lines through them). Every other built-in constant is a function, although the special symbols ¯, , and π are used as part of numeric literal notation.

Assignment

Another element that can be included in expressions is assignment, which is written with to define (also called "declare" in many other languages) a variable and to change its definition. A variable can only be defined once within a scope, and can only be changed if it has already been defined. However, it can be shadowed, meaning that it is defined again in an inner scope even though it has a definition in an outer scope already.

-
    x1  {x2  x3  x}
+↗️
    x1  {x2  x3  x}
 3
     x
 1
 

Assignment can be used inline in an expression, and its result is always the value being assigned. The role of the identifier used must match the value being assigned.

-
    2×a(Neg-)3
+↗️
    2×a(Neg-)3
 ¯6
     a
 ¯3
-- 
cgit v1.2.3