Description
Elements of sets may be any immutable object, such as integers, ring elements and lists of such. Ideals may also be elements of sets.
i1 : A = set {1,2};

i2 : R = QQ[a..d];

i3 : B = set{a^2b*c,b*d}
2
o3 = set {a  b*c, b*d}
o3 : Set

Set operations, such as
membership,
union,
intersection,
difference,
Cartesian product,
Cartesian power, and
subset are available. For example,
i4 : toList B
2
o4 = {b*d, a  b*c}
o4 : List

i5 : member(1,A)
o5 = true

i6 : member(b*c+a^2,B)
o6 = true

i7 : A ** A
o7 = set {(1, 1), (1, 2), (2, 1), (2, 2)}
o7 : Set

i8 : A^**2
o8 = set {(1, 1), (1, 2), (2, 1), (2, 2)}
o8 : Set

i9 : set{1,3,2}  set{1}
o9 = set {2, 3}
o9 : Set

i10 : set{4,5} + set{5,6}
o10 = set {4, 5, 6}
o10 : Set

i11 : set{4,5} * set{5,6}
o11 = set {5}
o11 : Set

i12 : set{1,3,2} === set{1,2,3}
o12 = true

Ideals in Macaulay2 come equipped with a specific sequence of generators, so the following two ideals are not considered strictly equal, and thus the set containing them will appear to have two elements.
i13 : I = ideal(a,b); J = ideal(b,a);
o13 : Ideal of R
o14 : Ideal of R

i15 : I == J
o15 = true

i16 : I === J
o16 = false

i17 : C = set(ideal(a,b),ideal(b,a))
o17 = set {ideal (a, b), ideal (b, a)}
o17 : Set

However, if you
trim the ideals, then the generating sets will be the same, and so the set containing them will have one element.
i18 : C1 = set(trim ideal(a,b),trim ideal(b,a))
o18 = set {ideal (b, a)}
o18 : Set

A set is implemented as a HashTable, whose keys are the elements of the set, and whose values are all 1. In particular, this means that two objects are considered the same exactly when they are strictly equal, according to ===.