From 7e5d0fcc39fd8a683fc7010af064849b454b432b Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 4 Jun 2022 17:40:31 -0400 Subject: Further editing --- docs/doc/match.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'docs/doc/match.html') diff --git a/docs/doc/match.html b/docs/doc/match.html index 95336280..767a4bb5 100644 --- a/docs/doc/match.html +++ b/docs/doc/match.html @@ -23,9 +23,9 @@ 0

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.

+

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. And because an array never matches an atom, the result if only one argument is an atom is 0. The interesting case is when both arguments are atoms, discussed below.

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.

+

Atoms in BQN have six possible types: number, character, function, 1-modifier, 2-modifier, and namespace. Equality testing isn't 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˙
 ⟨ 0 0 0 ⟩
@@ -37,13 +37,13 @@
     1.25 = 1 + 0.25
 1
 
-

Mutable types are more difficult. Here there are three cases:

+

Operations and namespaces are more difficult. Here there are three cases:

-

The first two are fairly similar to how numbers and arrays work. Primitives and compounds like trains, or modifiers with bound operands, are immutable, so they are defined purely by what components they contain.

+

The first two are fairly similar to how numbers and arrays work. Primitives and compounds like trains, or modifiers with bound operands, are immutable, so they're defined purely by what components they contain.

↗️
    +,-,× = +,-,÷
 ⟨ 1 1 0 ⟩
 
@@ -66,7 +66,7 @@
     F 5   # Another result—the definition of insanity!
 13
 
-

(A side note is that BQN restricts what can cause these side effects: they can only happen by calling a block function or modifier, and never a primitive or purely tacit operation). Now suppose we share the value of F with another variable. When we apply G, the result of F might change, but so does F1! This effect is called aliasing.

+

(A side note is that BQN restricts what can cause these side effects: they can only happen by calling a block function or modifier, and never a primitive or purely tacit operation). Now suppose we share the value of F with another variable like F1 below. When we apply G, the result of F might change, but so does F1! This effect is called aliasing.

↗️
    F1  F
     {𝕏 6}¨ FF1
 ⟨ 14 14 ⟩
@@ -76,7 +76,7 @@
     {𝕏 6}¨ FF1
 ⟨ 9 9 ⟩
 
-

In some cases you might not be able to demonstrate aliasing so cleanly. A function such as a random number generator changes its own state, so calling one function will change the other. Comparison tells you whether two blocks are the same.

+

In some cases you might not be able to demonstrate aliasing so cleanly. A function such as a random number generator changes its own state, so calling one function will change the other. But comparison tells you directly whether two blocks are the same.

↗️
    f = f1
 1
 
-- cgit v1.2.3