From 336798e9a6f98b3c717c3c4d23d2112bdc8ed61e Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 28 Feb 2023 22:04:31 -0500 Subject: Fix weird header depths --- docs/doc/selfcmp.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/doc/selfcmp.html') diff --git a/docs/doc/selfcmp.html b/docs/doc/selfcmp.html index d4cb1cbc..ada4eca5 100644 --- a/docs/doc/selfcmp.html +++ b/docs/doc/selfcmp.html @@ -148,7 +148,7 @@ ⟨ 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-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.

-

Deduplicate

+

Deduplicate

Deduplicate removes every major cell from the argument that matches an earlier cell, resulting in an array with the same rank but possibly a shorter length. It might also be described as returning the unique major cells of the argument, ordered by first occurrence. Deduplicate Under Reverse () orders by last occurrence instead.

↗️
     >"take""drop""drop""pick""take""take"
 ┌─      
@@ -222,7 +222,7 @@
 

One way to view this relationship is from the perspective of linear algebra, where an idempotent transformation is called a "projection". That means that the argument might be any value but the result is part of a smaller class of values, and any argument from that smaller class is left the same. What arrays do the two functions project to? The result of Deduplicate is an array with no repeated major cells. The result of Classify is a list of natural numbers, but it also has an additional property: each number in the list is at most one higher than the previous numbers, and the first number is zero. This comes from the way Classify numbers the cells of its argument. When it finds a cell that hasn't appeared before (at a lower index), it always chooses the next higher number for it.

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. 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

+

Mark Firsts

Mark Firsts () is the simplest numeric 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 ⟩
@@ -236,7 +236,7 @@
 ⟨ 0 0 1 0 1 ⟩
 

Remember that you don't have to apply the result of Mark Firsts to the same array you got it from! For example, it might be useful in a database application to find unique values in a particular column but use these to filter the entire table, or one other column.

-

Occurrence Count

+

Occurrence Count

Occurrence Count () is a somewhat more sophisticated take on the idea behind Mark Firsts: instead of just testing whether a cell is a duplicate, it returns a number indicating how many previous cells match it. This means that Mark Firsts can be implemented with 0=⊒.

↗️
       27181718284
 ⟨ 0 0 0 0 1 1 2 1 1 2 0 ⟩
-- 
cgit v1.2.3