tact
tact copied to clipboard
Introduce `set` type
It should support the following operations (it's a rough draft, please comment):
-
emptySet()
: create an empty set; -
s.exist(e)
: returnstrue
if the elemente
is in the set andfalse
otherwise; -
s.add(e)
: modify the sets
by adding a new elemente
to it (we can discuss what this function should return, for instance it can be a boolean signaling ife
was already in the set); -
s.replace(e1, e2)
: removee1
and adde2
-- let's discuss the precise semantics or if this is even needed; -
s1.union(s2)
:s1
gets extended with the elements ofs2
(we might want to also introduce a non-modifying version of this:fun union(s1: set<T>, s2: set<T>): set<T>
whereT
is some "setable" type) -
s1.intersect(s2)
:s1
will keep only the elements common betweens1
ands2
(the non-modifying version can be also added) - ... (set difference, symmetric difference)
-
foreach
statement support for sets -
toCell()
, etc.