From 2afb23928e1984d475cc460e1672e8f6fa0e4dbe Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 11 Aug 2021 17:21:31 -0400 Subject: Allow clicking on header to get fragment link --- docs/doc/match.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/doc/match.html') diff --git a/docs/doc/match.html b/docs/doc/match.html index 74fc83a3..b162bd3b 100644 --- a/docs/doc/match.html +++ b/docs/doc/match.html @@ -4,7 +4,7 @@ BQN: Match -

Match

+

Match

The primitive Match () tests whether its two argument arrays are considered equivalent in BQN, returning 1 if so and 0 otherwise. Not Match () is the opposite, returning 1 if the two arrays aren't equivalent and 0 if they are.

↗️
    "abc"  'a''b''c'
 1
@@ -24,7 +24,7 @@
 

Match compares arrays based on their fundamental properties—shape and elements—and not the fill element, which is an inferred property. Since it can be computed differently in different implementations, using the fill element in Match could lead to some confusing results. Even if the implementation doesn't define a fill for 'a''b''c', it should still be considered to match "abc".

To give a precise definition, two arrays are considered to match if they have the same shape and all corresponding elements from the two arrays match. Every array has a finite depth so this recursive definition always ends up comparing non-arrays, or atoms. An array never matches an atom, so the result if only one argument is an atom is 0. The interesting case is when both arguments are atoms, discussed below.

-

Atomic equality

+

Atomic equality

Atoms in BQN have six possible types: number, character, function, 1-modifier, 2-modifier, and namespace. Equality is not allowed to fail for any two arguments, so it needs to be defined on all of these types.

Starting with the easiest rules, values with different types are never equal to each other.

↗️
    'a', +, 3 = -», '+', 3˙
@@ -54,7 +54,7 @@
 ⟨ 1 ⟩
 

This approach can't tell you whether two functions are mathematically different—that is, whether they ever return different results given the same arguments (this is an undecidable problem, and also gets confusing since "different" is included in its own definition). However, if two functions compare equal, then they will always return the same results.

-

Block equality

+

Block equality

The final point above about block instances is subtler. An instance of a block function or modifier is mutable, meaning that its behavior can change over the course of a program. Consider the following two functions:

↗️
    FG  { a10  {a+𝕩}{a𝕩} }
 ⟨ *function* *function* ⟩
-- 
cgit v1.2.3