Topic: APLX Help : Help on APL language : APL Primitives : ≡ Match
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

Match


Two-argument form  See also one-argument form Depth

The match function will test whether its arguments are the same in every respect - depth, rank, shape and corresponding elements. The result is always a scalar 1 or 0.

             3≡3                     (Two scalars are identical)
       1
             3≡,3                    (Scalar does not match a vector)
       0
             4 7.1 8 ≡ 4 7.2 8       (Shape is the same but values are not)
       0
             (3 4⍴⍳12)≡3 4⍴⍳12       (Two matrices are identical)
       1
             (3 4 ⍴⍳12)≡⊂3 4⍴⍳12     (Simple matrix does not match an enclosed
       0                              version of itself)
             VEC←'ABC' 'DEF'         (Two element vector of 'ABC' 'DEF)
             VEC
       ABC DEF
             ⍴VEC                    (Length 2)
       2
             VEC≡'ABCDEF'            (Does not match the 6 element vector
       0                              'ABCDEF')

Empty arrays are considered the same only if they have the same type, rank, shape and prototype.

             (⍳0)≡''                 (Types are different)
       0
             (2 0⍴0)≡0 2⍴0           (Shapes are different)
       0
             (0⍴⊂1 2 3)≡0⍴⊂2 2⍴⍳4    (Prototypes are different)
       0

The comparisons done by this operation are affected by ⎕CT, the comparison tolerance value.

If the arguments contain object (or class) references, the elements are considered equal if the reference indices are the same, i.e. if they refer to the same entry in APL's internal table of objects. For internal objects, this will be true if and only if the elements refer to the same object. Note that different objects which happen to contain the same properties are not considered equal.


Topic: APLX Help : Help on APL language : APL Primitives : ≡ Match
[ Previous | Next | Contents | Index | APL Home ]