From 18d1bce85de22f8bc7a08453618c7d9e94b61f92 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 28 May 2022 21:55:15 -0400 Subject: Editing --- docs/doc/hook.html | 12 ++++++------ docs/doc/identity.html | 15 ++------------- 2 files changed, 8 insertions(+), 19 deletions(-) (limited to 'docs/doc') diff --git a/docs/doc/hook.html b/docs/doc/hook.html index e300796a..a81c7b7d 100644 --- a/docs/doc/hook.html +++ b/docs/doc/hook.html @@ -102,7 +102,7 @@

Description

-

In the general case, I think of Before as using 𝔽 as a preprocessing function applied to 𝕨 (when there are two arguments) and After as using 𝔾 as preprocessing for 𝕩. Then the other operand is called on the result and remaining argument. Here are some simple calls with Pair (): the result is a pair that corresponds to 𝕨𝕩, but one or the other result has been modified by the pointy-side function.

+

In the general case, I think of Before as using 𝔽 as a preprocessing function applied to 𝕨 (when there are two arguments), and After as using 𝔾 as preprocessing for 𝕩. Then the other operand is called on the result and remaining argument. Here are some simple calls with Pair (): the result is a pair that corresponds to 𝕨𝕩, but one or the other result has been modified by the pointy-side function.

↗️
    9  2
 ⟨ 3 2 ⟩
 
@@ -117,7 +117,7 @@
 ↗️
    {𝕩<0}¨/ 4¯21¯3¯3
 ⟨ ¯2 ¯3 ¯3 ⟩
 
-

As < is a pervasive function, there's no need for the Each (¨) in this case, and the clunky block function {𝕩<0} can also be written smaller with a combinator, as <0. More on that in the next section…

+

As < is a pervasive function, there's no need for the Each (¨) in this case, and the clunky block function {𝕩<0} can also be written smaller with a combinator, as <0. More on that in the next section…

↗️
    <0/ 4¯21¯3¯3
 ⟨ ¯2 ¯3 ¯3 ⟩
 
@@ -126,7 +126,7 @@ ↗️
    <0  4¯21¯3¯3
 ⟨ 0 1 0 1 1 ⟩
 
-

If we expand <0 x, we get x < (0 x), which doesn't quite make sense. That's because 0 has a subject role, but always applies its operands as functions. It's more accurate to use x < (0{𝔽} x), or just skip ahead to x < 0.

+

If we expand <0 x, we get x < (0 x), which doesn't quite make sense. That's because 0 has a subject role, but always applies its operands as functions. It's more accurate to use x < (0{𝔽} x), or just skip ahead to x < 0.

Similar reasoning gives the following expansions:

@@ -150,7 +150,7 @@

Note that when there are two arguments, the constant "swallows" the one on the same side, so that the function is applied to the constant and the argument on the opposite side.

-

As in a train, if you want to use a function as a constant then you need to be explicity about it, with the Constant (˙) modifier.

+

As in a train, if you want to use a function as a constant then you need to be explicit about it, with the Constant (˙) modifier.

↗️
    3 (˙) 'a'+↕12
 ┌─      
 ╵"abcd  
@@ -161,7 +161,7 @@
 

In the more extreme case of wanting a modifier operand, you might try ({}˙), or (⊣⋈{}˙), or just cheat with .

Combinations

If you like to go tacit, you'll likely end up stringing together a few s and s at times. Of course the effects are entirely determined by the left-to-right precedence rule for modifiers, but it's interesting to examine what happens in more detail.

-

In the pattern FGH, the ordering doesn't matter at all! That is, it means (FG)H, but this is exactly the same function as F(GH). In both cases, F is applied to 𝕨, H is applied to 𝕩, and G acts on both the results.

+

In the pattern FGH, the ordering doesn't matter at all! That is, it means (FG)H, but this is the same function as F(GH). In both cases, F is applied to 𝕨, H is applied to 𝕩, and G acts on both the results (the parentheses do change whether F or H is called first, which only matters if they have side effects).

↗️
    4 - 2
 ⟨ ¯4 7.38905609893065 ⟩
 
@@ -187,4 +187,4 @@ (⌊≠÷2˙) "quicksort" # Use to partition 𝕩 ⟨ "ic" "quksort" ⟩
-

Three is rare, but I use two s all the time, as well as followed by , for example the <'a'/ filter on the front page. I think a combination like lotsofstuff/ x reads very nicely when moving from left to right. When I see / I know that I'm filtering x and can read the rest with that context. The reason that has all this power, but not , has nothing to do with the modifiers themselves, as they're completely symmetrical. It's all in the way BQN defines modifier grammar, left to right.

+

Three is rare, but I use two s all the time, as well as followed by , for example the <'a'/ filter on the front page. I think a combination like lotsofstuff/ x reads very nicely when moving from right to left. When I see / I know that I'm filtering x and can read the rest with that context. The reason has all this power, but not , has nothing to do with the modifiers themselves, as they're completely symmetrical. It's all in the way BQN defines modifier grammar, left to right.

diff --git a/docs/doc/identity.html b/docs/doc/identity.html index 520e1657..5ef3bde7 100644 --- a/docs/doc/identity.html +++ b/docs/doc/identity.html @@ -18,7 +18,7 @@ "left" "right" "left"
-

Depending on your past experiences, this could cause some confusion: built-in support for functions that do nothing? Documentation should say why a feature's there and how to use it, not just what it does, so we'll try to address this below. The most important single use is for tacit programming, but there are a variety of other uses as well.

+

Depending on your past experiences, this could cause some confusion: built-in support for functions that do nothing? Documentation should say why a feature's there and how to use it, not just what it does, so we'll try to address this below. The most important single use is for tacit programming, but there are a variety of other uses as well.

Of course, it's easy to write block functions {𝕩} and {𝕨} that return particular arguments. While I would already make and primitives just because they are common and important, there are also specific disadvantages to using blocks. They fail to indicate that there are no side effects, as primitives would, and they also need special casing for the interpreter to manipulate them when applying Undo () or making other inferences.

Filling arrays

What's the easiest way to create a matrix with 0 on the first row, 1 on the second, and so on? Probably this one, with table:

@@ -68,19 +68,8 @@ 4.5

A larger class of block functions can be translated just by adding parentheses and ˙ (there's a discussion of this technique in APL here). It's helpful when writing tacit code to know that Fn applies Fn to the left argument only and Fn applies it to the right argument—these can be read "Fn of left" and "Fn of right".

-

Syntax tricks

+

One more thing

You've probably seen used in documentation to display the value of a variable being assigned. This is a hack, and in most contexts •Show should be used to display values.

↗️
     a  "show this"
 "show this"
 
-

More importantly, can be used to ignore a right argument for modified assignment, to apply a function "in place" to a variable without writing the variable name twice.

-↗️
    a  @
-"siht wohs"
-
-

In APL a tack can be used to avoid stranding numbers together. In BQN, stranding is explicit, and there's no need!

-↗️
    ÷23 24
-3
-    ÷23 24
-3
-
-

(Wow, what a useless section.)

-- cgit v1.2.3