4,494
edits
m (→History) |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
Line 9: | Line 9: | ||
1 2 3 ≡ 1 2 5 | 1 2 3 ≡ 1 2 5 | ||
0 | 0 | ||
</ | </syntaxhighlight> | ||
Using [[strand notation]] to create [[nested]] arrays, we see that Match also compares elements nested within arrays: | Using [[strand notation]] to create [[nested]] arrays, we see that Match also compares elements nested within arrays: | ||
<source lang=apl> | <source lang=apl> | ||
(1 2)3 ≡ (2 1)3 | (1 2)3 ≡ (2 1)3 | ||
0 | 0 | ||
</ | </syntaxhighlight> | ||
Arrays with the same elements but different shapes do not match. Unlike [[Equal to]], Match never gives a [[RANK ERROR]] or [[LENGTH ERROR]] because of argument shapes. | Arrays with the same elements but different shapes do not match. Unlike [[Equal to]], Match never gives a [[RANK ERROR]] or [[LENGTH ERROR]] because of argument shapes. | ||
<source lang=apl> | <source lang=apl> | ||
Line 21: | Line 21: | ||
'a' ≡ ,'a' ⍝ Scalar versus singleton | 'a' ≡ ,'a' ⍝ Scalar versus singleton | ||
0 | 0 | ||
</ | </syntaxhighlight> | ||
Match depends on [[comparison tolerance]]. Here two arrays which are not exactly identical are still reported as matching: | Match depends on [[comparison tolerance]]. Here two arrays which are not exactly identical are still reported as matching: | ||
<source lang=apl> | <source lang=apl> | ||
Line 31: | Line 31: | ||
a {⎕CT←0⋄⍺≡⍵} b ⍝ ...but not intolerantly | a {⎕CT←0⋄⍺≡⍵} b ⍝ ...but not intolerantly | ||
0 | 0 | ||
</ | </syntaxhighlight> | ||
== Description == | == Description == | ||
Line 43: | Line 43: | ||
=== APL model === | === APL model === | ||
The following model implements Match in [[Dyalog APL]]. Because Match compares the same characteristic of both arguments, [[Over]] (<source lang=apl inline>⍥</ | The following model implements Match in [[Dyalog APL]]. Because Match compares the same characteristic of both arguments, [[Over]] (<source lang=apl inline>⍥</syntaxhighlight>) is used throughout. | ||
<source lang=apl> | <source lang=apl> | ||
Match ← { | Match ← { | ||
Line 52: | Line 52: | ||
⍺∧.∇⍥,⍵ ⍝ Recurse | ⍺∧.∇⍥,⍵ ⍝ Recurse | ||
} | } | ||
</ | </syntaxhighlight> | ||
{{Works in|[[Dyalog APL 18.0]]}} | {{Works in|[[Dyalog APL 18.0]]}} | ||
Line 64: | Line 64: | ||
* [http://microapl.com/apl_help/ch_020_020_360.htm APLX] | * [http://microapl.com/apl_help/ch_020_020_360.htm APLX] | ||
* [https://mlochbaum.github.io/BQN/doc/match.html BQN] | * [https://mlochbaum.github.io/BQN/doc/match.html BQN] | ||
* J [https://www.jsoftware.com/help/dictionary/d122.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/minusco#dyadic NuVoc] (as <source lang=j inline>-:</ | * J [https://www.jsoftware.com/help/dictionary/d122.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/minusco#dyadic NuVoc] (as <source lang=j inline>-:</syntaxhighlight>) | ||
== See also == | == See also == |