x === y -- returns true or false depending on whether the expressions x and y are strictly equal.
Strictly equal expressions have the same type, so
0===0. and
0===0/1 are false; the three types involved here are
ZZ,
RR, and
QQ.
If x and y are
mutable then they are strictly equal only if they are identical (i.e., at the same address in memory). For details about why strict equality cannot depend on the contents of mutable hash tables, see
hashing. On the other hand, if x and y are non-mutable, then they are strictly equal if and only if all their contents are strictly equal.
i1 : {1,2,3} === {1,2,3}
o1 = true
|
i2 : {1,2,3} === {2,1,3}
o2 = false
|
For some types, such as ring elements and matrices, strict equality is the same as mathematical equality. This tends to be the case for objects for which computation is not required to test equality.
i3 : R = QQ[a..d];
|
i4 : a^2+b === b+a^2
o4 = true
|
i5 : ideal(a^2+b,c*d) === ideal(b+a^2,c*d+b+a^2)
o5 = false
|
i6 : matrix{{a,b,c}} === matrix{{a,b,c}}
o6 = true
|
i7 : matrix{{a,b,c}} === transpose matrix{{a},{b},{c}}
o7 = false
|