next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: same

same -- whether everything in a list is the same

Synopsis

Description

i1 : same {1, 1, 1, 1}

o1 = true
i2 : same {1, 2, 1, 1}

o2 = false

The comparison is done with "===", which is quick, but not always intuitive. Here is a simple example of what can go wrong:

i3 : R = QQ[x,y,z];
i4 : L = {gcd{x,y}, x/x, 1}

o4 = {1, 1, 1}

o4 : List
i5 : same L

o5 = false

We can see the problem by asking Macaulay2 to display the class of each element of L.

i6 : apply(L, class)

o6 = {R, frac(R), ZZ}

o6 : List

The first 1 is an element of the ring R, the second 1 is an element of the fraction field of R, and the third 1 is an integer. Thus Macaulay2 thinks of these three elements as being pairwise unequal.

See also