Table of Contents
Genius incorpora un juego básico de funcionalidades teoréticas. En la actualidad, un conjunto es sólo un vector (o una matriz). Cada objeto distinto se trata como un elemento diferente.
Al igual que los vectores, los objetos en conjuntos pueden incluir números, cadenas, null
, matrices y vectores. En un futuro se plantea tener un tipo determinado de conjuntos, en lugar de utilizar vectores. Tenga en cuenta que los números en coma flotante son distintos de los enteros, y que parecen iguales. Esto significa que Genius los tratará como términos distintos, usando las constantes 0
y 0.0
. La constante null
se trata como un conjunto vacío.
To build a set out of a vector, use the
MakeSet
function.
Currently, it will just return a new vector where every element is unique.
genius>
MakeSet([1,2,2,3])
= [1, 2, 3]
Similarly there are functions
Union
,
Intersection
,
SetMinus
, which
are rather self explanatory. For example:
genius>
Union([1,2,3], [1,2,4])
= [1, 2, 4, 3]
Note that no order is guaranteed for the return values. If you wish to sort the vector you
should use the
SortVector
function.
For testing membership, there are functions
IsIn
and
IsSubset
,
which return a boolean value. For example:
genius>
IsIn (1, [0,1,2])
= true
The input IsIn(x,X)
is equivalent to
IsSubset([x],X)
. Note that since the empty set is a subset
of every set, IsSubset(null,X)
is always true.