ToSet
Converts an object to a set.
Syntax
-
ToSet(X)
-
X
is any object
-
Description
If X
is any object, then ToSet(X)
returns a set with the same content as X
, to the extent it is possible.
-
If
X
isn’t a container,ToSet(X)
returns the singleton set{ X }
. This applies to numbers, booleans, colours, and sounds. -
If
X
is a container,ToSet(X)
returns the set of all the elements inX
.These object types include vectors, matrices, lists, sets, strings, structures, and pixmaps. In the case of strings and pixmaps, the elements are characters and colours, respectively.
Notice that
#ToSet(X)
might well be (much) smaller than#X
, because a set cannot contain duplicates.
Examples
ToSet(IdentityMatrix(100))
{1, 0}
pm ≔ ColorGradient(100, 100, "red", "black");
'(#pm, #ToSet(pm))
10000 100
s ≔ "I suspect nargles are behind it."; ToSet(s)
{s, c, u, a, I, n, g, d, t, r, ., i, h, b, p, , e, l}
See also
-
Type conversion functions (list)