From 85878912035fd3fb3582db60ef1fc06b459fe67a Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 15 Jul 2021 08:35:30 -0400 Subject: Rename self-comparison to self-search --- docs/doc/selfcmp.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'docs/doc/selfcmp.html') diff --git a/docs/doc/selfcmp.html b/docs/doc/selfcmp.html index 9188c69c..bc99ef43 100644 --- a/docs/doc/selfcmp.html +++ b/docs/doc/selfcmp.html @@ -1,10 +1,10 @@ - BQN: Self-comparison functions + BQN: Self-search functions -

Self-comparison functions

+

Self-search functions

@@ -131,11 +131,11 @@ -

BQN has four self-comparison functions, Classify (), Occurrence Count (), Mark Firsts (), and Deduplicate (). Each of these is a monadic function that obtains its result by comparing each major cell of the argument (which must have rank at least 1) to the earlier major cells with match. For example, Mark Firsts indicates the cells that don't match any earlier cell, making them the first of their kind.

+

BQN has four self-search functions, Classify (), Occurrence Count (), Mark Firsts (), and Deduplicate (). Each of these is a monadic function that obtains its result by comparing each major cell of the argument (which must have rank at least 1) to the earlier major cells with match. For example, Mark Firsts indicates the cells that don't match any earlier cell, making them the first of their kind.

↗️
     "abaacb"
 ⟨ 1 1 0 0 1 0 ⟩
 
-

When the argument is a list, its major cells are units and thus contain one element each, so it's just as valid to say that a self-comparison function compares elements of its argument. Only with a higher-rank argument does the major cell nature become apparent.

+

When the argument is a list, its major cells are units and thus contain one element each, so it's just as valid to say that a self-search function compares elements of its argument. Only with a higher-rank argument does the major cell nature become apparent.

↗️
     arr  >"abc""dcb""abc""bcd""dcb"
 ┌─     
 ╵"abc  
@@ -147,9 +147,9 @@
      arr
 ⟨ 1 1 0 1 0 ⟩
 
-

The result has one number for each major cell, or in other words is a list with the same length as its argument. Three self-comparison functions follow this pattern, but Deduplicate () is different: it returns an array of the same rank but possibly a shorter length than the argument.

+

The result has one number for each major cell, or in other words is a list with the same length as its argument. Three self-search functions follow this pattern, but Deduplicate () is different: it returns an array of the same rank but possibly a shorter length than the argument.

Classify

-

Classify is the universal self-comparison function, in that it preserves all the self-comparison information in its argument. It gives each different cell value a natural number, ordered by first appearance.

+

Classify is the universal self-search function, in that it preserves all the self-search information in its argument. It gives each different cell value a natural number, ordered by first appearance.

↗️
     562251
 ⟨ 0 1 2 2 0 3 ⟩
 
@@ -160,7 +160,7 @@ 0 1 2 2 0 3 ┘ -

Applying Classify before another self-comparison function will never change the result, except in the case of Deduplicate (), which constructs its result from cells in the argument. In particular, Classify is idempotent, meaning that applying it twice is the same as applying it once.

+

Applying Classify before another self-search function will never change the result, except in the case of Deduplicate (), which constructs its result from cells in the argument. In particular, Classify is idempotent, meaning that applying it twice is the same as applying it once.

↗️
       "dbaedcbcecbcd"
 ⟨ 1 1 1 1 0 1 0 0 0 0 0 0 0 ⟩
       "dbaedcbcecbcd"
@@ -208,7 +208,7 @@
 

Applying both Classify and Deduplicate gives an array that has both properties (this isn't the case for all pairs of projections—we need to know that Classify maintains the uniqueness property for Deduplicate and vice-versa). It has no duplicate major cells, and it's a list of natural numbers that starts with 0 and never goes up by more than one. Taken together, these are a tight constraint! The first element of the argument has to be 0. The next can't be 0 because it's already appeared, but it can't be more than one higher—it has to be 1. The next can't be 0 or 1, and has to be 2. And so on. So the result is always n for some n. In fact it's possible to determine the length as well, by noting that each function preserves the number of unique major cells in its argument. Classify does this because distinct numbers in the output correspond exactly to distinct major cells in the input; Deduplicate does this because it only removes duplicate cells, not distinct ones. So the final result is n, where n is the number of unique major cells in the argument.

Mark Firsts

See the APL Wiki page on this function as well.

-

Mark Firsts () is the simplest self-comparison function: it returns 0 for any major cell of the argument that is a duplicate of an earlier cell and 1 for a major cell that's the first with its value. To implement Deduplicate in terms of Mark Firsts, just filter out the duplicates with /.

+

Mark Firsts () is the simplest self-search function: it returns 0 for any major cell of the argument that is a duplicate of an earlier cell and 1 for a major cell that's the first with its value. To implement Deduplicate in terms of Mark Firsts, just filter out the duplicates with /.

↗️
       314159265
 ⟨ 1 1 1 0 1 1 1 1 0 ⟩
 
-- 
cgit v1.2.3