# 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
  )
