From e2b07a5fd0bbaad232c717fb90a31d6c61d72bd4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 14 Jul 2022 20:06:50 -0400 Subject: Try to include previous variable definitions in REPL links --- docs/doc/quick.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'docs/doc/quick.html') diff --git a/docs/doc/quick.html b/docs/doc/quick.html index 3b89af8c..af70a7b7 100644 --- a/docs/doc/quick.html +++ b/docs/doc/quick.html @@ -62,7 +62,7 @@

The function Lower is defined to be -diff, but it uses a different arrow to do this. This is an export, and it declares that Lower is a field of a namespace that can be accessed from the outside. Having a in it is also what makes the block define a namespace. Lower itself won't be used for a while, but Upper is accessed a few lines down, with case.Upper.

Lower is created with a modifier again, this time the 2-modifier . We've now seen one each of the three primitive types: function, 1-modifier, and 2-modifier. There are a lot of primitives, but some simple rules tell you which type they have. Primitives are functions by default, but superscript characters are 1-modifiers (´⁼˘¨˜` in our program), and ones with an unbroken circle are 2-modifiers (⟜∘⌾; is a broken circle so it's a function). Variable names follow a similar system, where functions start with an uppercase letter and subjects with a lowercase one.

After () takes two operands, - and diff, to produce a function—specifically, it binds diff as the right argument of -, so that calling it on an argument subtracts diff from that argument.

-↗️
    -diff 'G'
+↗️
    -diff 'G'
 'g'
 
     'G' - diff
@@ -147,7 +147,7 @@
 ⟨ "Hello" "World" ⟩
 

That converts the first character of each string to uppercase! case.Upper is the case conversion function defined before, so that part makes sense. The rest of the function, (¨), would be pronounced "Under the First of Each", which… pretty much makes sense too? The First Each function extracts the first element of each list in hw, the part that used to be "hw" but is now "HW".

-↗️
    ¨ hw
+↗️
    ¨ hw
 "HW"
 
     case.Upper "hw"
@@ -163,14 +163,14 @@
 
•Out hw   ⥊⍉ [hw, ", ""!"]  # Hello, World!
 

None of these functions have a subject to the left, so they're all evaluated as prefix functions. But first, we have the array notation []. This syntax forms an array from its major cells hw and ", ""!" (another strand, a list of two strings). Because the major cells are both lists, we have another rank 2 array.

-↗️
    [hw, ", ""!"]
+↗️
    [hw, ", ""!"]
 ┌─                 
 ╵ "Hello" "World"  
   ", "    "!"      
                   ┘
 

The reason for forming this array is to interleave the elements, or we might say to read down the columns rather than across the rows. This ordering is done with a Transpose to exchange the two axes, then a Deshape to flatten it out, giving a list.

-↗️
     [hw, ", ""!"]
+↗️
     [hw, ", ""!"]
 ┌─              
 ╵ "Hello" ", "  
   "World" "!"   
@@ -180,7 +180,7 @@
 ⟨ "Hello" ", " "World" "!" ⟩
 

Finally, Join combines this list of strings into a single string.

-↗️
    hw   ⥊⍉ [hw, ", ""!"]
+↗️
    hw   ⥊⍉ [hw, ", ""!"]
     hw
 "Hello, World!"
 
@@ -249,7 +249,7 @@ (¨ GV ˜ ·+`GS) r

The first line here applies Proc to each character and the one before it, using ' ' as the character "before" the first. Proc{»𝔽¨} 𝕩 is a fancy way to write (»𝕩) Proc¨ 𝕩, which we'll explain in a moment. First, here's what the Nudge function » does.

-↗️
    hw
+↗️
    hw
 "Hello, World!"
     »hw
 " Hello, World"
@@ -257,7 +257,7 @@
 

It moves its argument forward by one, adding a space character (the array's fill) but keeping the same length. This gives the previous characters that we want to use for Proc's left argument. Here Each is used with two arguments, so that it iterates over them simultaneously, like a "zip" in some languages.

What about the fancy syntax Proc{»𝔽¨} 𝕩? The block {»𝔽¨} is an immediate 1-modifier because it uses 𝔽 for an operand but not the arguments 𝕨 or 𝕩. This means it acts on Proc only, giving »Proc¨, which is a train because it ends in a function . Following the rules for a 3-train, (»Proc¨)𝕩 expands to (»𝕩) Proc¨ (𝕩), and since is the identity function, 𝕩 is 𝕩.

Since a display of lots of namespaces isn't too enlightening, we'll skip ahead and show what the results of GV and GS on those lists would be. GV turns each character into a string, except it makes a space into the empty string. GS has a 1 in the places where we want to split the string.

-↗️
    sp  ' '=hw
+↗️
    sp  ' '=hw
     gv  (1-sp) ¨ hw
     gs  sp  »= hw
 
@@ -312,18 +312,18 @@
 
 
 

There are actually three train groupings here: from right to left, ·+`GS, GV ˜ , and ¨ . Two of them are 2-trains, which apply one function to the result of another, but the one with is a 3-train, applying a function to two results. In the end, functions GS and GV are applied to r. In fact, to evaluate the entire train we can replace these two functions with their results, giving ¨ (GV r) ˜ ·+`(GS r).

-↗️
    ¨ gv ˜ ·+`gs
+↗️
    ¨ gv ˜ ·+`gs
 ⟨ "Hel" "lo," "World!" ⟩
 

In this expression, Nothing can be removed without changing the meaning. It's used in the train to force +` to apply to GS as a 2-train instead of also taking ˜ as a left argument. The Scan +` is a prefix sum, progressively adding up the numbers in gs.

-↗️
    gs
+↗️
    gs
 ⟨ 0 0 0 1 0 0 1 0 0 0 0 0 0 ⟩
 
     +`gs
 ⟨ 0 0 0 1 1 1 2 2 2 2 2 2 2 ⟩
 

The next bit uses Swap to switch the order: gv ˜ +`gs is (+`gs) gv, but sometimes the different order can read better (here it was mostly to squeeze Nothing into the program, I'll admit). Group then splits gv up based on the indices given: the first three elements become element 0 of the result, the next three element 1, and the rest element 2.

-↗️
    (+`gs)  gv
+↗️
    (+`gs)  gv
 ┌─                                                                
 · ⟨ "H" "e" "l" ⟩ ⟨ "l" "o" "," ⟩ ⟨ ⟨⟩ "W" "o" "r" "l" "d" "!" ⟩  
                                                                  ┘
-- 
cgit v1.2.3