From 93f75e97685520cdad3afab0134e2f65e5e211e2 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 21 Jul 2020 19:48:24 -0400 Subject: =?UTF-8?q?Add=20Insert=20(=CB=9D)=201-modifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/doc/context.html | 2 +- docs/doc/fromDyalog.html | 8 ++++---- docs/doc/group.html | 6 +++--- docs/doc/transpose.html | 2 +- docs/doc/windows.html | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'docs/doc') diff --git a/docs/doc/context.html b/docs/doc/context.html index b4c5616f..8d108e5f 100644 --- a/docs/doc/context.html +++ b/docs/doc/context.html @@ -50,7 +50,7 @@ -

Unlike variables, BQN primitives have only one spelling, and a fixed role (but their values can be used in a different role by storing them in variables). Superscript glyphs ˜¨˘⁼⌜´` are used for 1-modifiers, and glyphs ∘○⊸⟜⌾⊘◶⚇⎉⍟ with an unbroken circle are 2-modifiers. Other primitives are functions. String and numeric literals are subjects.

+

Unlike variables, BQN primitives have only one spelling, and a fixed role (but their values can be used in a different role by storing them in variables). Superscript glyphs ˜¨˘⁼⌜´˝` are used for 1-modifiers, and glyphs ∘○⊸⟜⌾⊘◶⚇⎉⍟ with an unbroken circle are 2-modifiers. Other primitives are functions. String and numeric literals are subjects.

BQN's variables use another system, where the spelling indicates how the variable's value is used. A variable spelled with a lowercase first letter, like var, is a subject. Spelled with an uppercase first letter, like Var, it is a function. Underscores are placed where operands apply to indicate a 1-modifier _var or 2-modifier _var_. Other than the first letter or underscore, variables are case-insensitive.

The associations between spelling and syntactic role are considered part of BQN's token formation rules.

One rule for typing is also best considered to be a pre-parsing rule like the spelling system: the role of a brace construct {} with no header is determined by which special arguments it uses: it's a subject if there are none, but a 𝕨 or 𝕩 makes it at least a function, an 𝔽 makes it a 1- or 2-modifier, and a 𝔾 always makes it a 2-modifier.

diff --git a/docs/doc/fromDyalog.html b/docs/doc/fromDyalog.html index 0b9ca972..ec02f2e7 100644 --- a/docs/doc/fromDyalog.html +++ b/docs/doc/fromDyalog.html @@ -116,7 +116,7 @@ BQN ¨ -´ +˝ ˜ @@ -175,19 +175,19 @@ {+(𝕨×)´𝕩} {𝕨|1↓⌊÷`𝕨∾<𝕩} - +´×1 I guess + +˝×1 I guess N/A - + - + diff --git a/docs/doc/group.html b/docs/doc/group.html index 590b166b..2ec68f63 100644 --- a/docs/doc/group.html +++ b/docs/doc/group.html @@ -138,17 +138,17 @@ ⟨ ⟨⟩ ⟨⟩ "string" "with" ⟨⟩ "spaces" ⟩

However, trailing spaces are ignored because Group never produces trailing empty groups (to get them back we would use a dummy final character in the string). To avoid empty words, we should increase the word index only once per group of spaces. We can do this by taking the prefix sum of a list that is 1 only for a space with no space before it. To make such a list, we can use the Windows function. We will extend our list with an initial 1 so that leading spaces will be ignored. Then we take windows of the same length as the original list: the first includes the dummy argument followed by a shifted copy of the list, and the second is the original list. These represent whether the previous and current characters are spaces; we want positions where the previous wasn't a space and the current is.

-
    ((<´<˘)≠↕1∾⊢) ' '="  string with  spaces   "  # All, then filtered, spaces
+
    (<˝≠↕1∾⊢) ' '="  string with  spaces   "  # All, then filtered, spaces
 ┌─                                                 
 ╵ 1 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 1 1  
   0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0  
                                                   ┘
-    (⊢-˜¬×+`((<´<˘)≠↕1∾⊢))' '="  string with  spaces   "  # More processing
+    (⊢-˜¬×+`(<˝≠↕1∾⊢))' '="  string with  spaces   "  # More processing
 ┌─                                                         
 ╵  1  1 0 0 0 0 0 0  1 0 0 0 0  1  1 0 0 0 0 0 0  1  1  1  
   ¯1 ¯1 0 0 0 0 0 0 ¯1 1 1 1 1 ¯1 ¯1 2 2 2 2 2 2 ¯1 ¯1 ¯1  
                                                           ┘
-    ' '((⊢-˜¬×+`((<´<˘)≠↕1∾⊢))=⊔⊢)"  string with  spaces   "  # Final result
+    ' '((⊢-˜¬×+`(<˝≠↕1∾⊢))=⊔⊢)"  string with  spaces   "  # Final result
 ⟨ "string" "with" "spaces" ⟩
 
diff --git a/docs/doc/transpose.html b/docs/doc/transpose.html index 3b5af23b..93e5da73 100644 --- a/docs/doc/transpose.html +++ b/docs/doc/transpose.html @@ -3,7 +3,7 @@

Transpose

As in APL, Transpose () is a tool for rearranging the axes of an array. BQN's version is tweaked to align better with the leading axis model and make common operations easier.

Monadic Transpose

-

Transposing a matrix exchanges its axes, mirroring it across the diagonal. APL extends the function to any rank by reversing all axes, but this generalization isn't very natural and is almost never used. The main reason for it is to maintain the equivalence a MP b ←→ a MP b, where MP (+´<˘)×1 is the generalized matrix product. But even here APL's Transpose is suspect. It does much more work than it needs to, as we'll see.

+

Transposing a matrix exchanges its axes, mirroring it across the diagonal. APL extends the function to any rank by reversing all axes, but this generalization isn't very natural and is almost never used. The main reason for it is to maintain the equivalence a MP b ←→ a MP b, where MP +˝×1 is the generalized matrix product. But even here APL's Transpose is suspect. It does much more work than it needs to, as we'll see.

BQN's transpose takes the first axis of its argument and moves it to the end.

     a23456  23456
  2 3 4 5 6 
diff --git a/docs/doc/windows.html b/docs/doc/windows.html
index c20d6591..113d5ffd 100644
--- a/docs/doc/windows.html
+++ b/docs/doc/windows.html
@@ -81,11 +81,11 @@
 

A common task is to pair elements, with an initial or final element so the total length stays the same. This can also be done with a pairwise reduction, but another good way (and more performant without special support in the interpreter) is to add the element and then use windows matching the original length. Here both methods are used to invert +`, which requires we take pairwise differences starting at initial value 0.

    -˜´˘20 +` 3211
 ⟨ 3 2 1 1 ⟩
-    ((-˜´<˘)≠↕0∾⊢) +` 3211
+    (-˜˝≠↕0∾⊢) +` 3211
 ⟨ 3 2 1 1 ⟩
 

This method extends to any number of initial elements. We can modify the running sum above to keep the length constant by starting with two zeros.

-
    ((+´<˘)≠↕(20)) 2,6,0,1,4,3
+
    (+˝≠↕(20)) 2,6,0,1,4,3
 ⟨ 2 8 8 7 5 8 ⟩
 
-- cgit v1.2.3
Operators
Syntax Monadic Dyadic
´
˝
or `
¨ ¨
˜
f.g (f´<˘)g1
f.g f˝g1
.f f
Ag Ag
fB fB