1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
# Basic set theory functions for Genius
# FIXME: Genius should really implement native set type
SetHelp ("Union", "sets", "Returns a set theoretic union of X and Y (X and Y are vectors pretending to be sets)");
function Union(X,Y) =
(
for x in X do
if not IsIn(x,Y) then Y@(elements(Y)+1)=x;
Y
)
SetHelp ("MakeSet", "sets", "Returns a set where every element of X appears only once");
function MakeSet(X) =
(
S = null;
for x in X do
if not IsIn(x,S) then S@(elements(S)+1)=x;
S
)
|