tact icon indicating copy to clipboard operation
tact copied to clipboard

Introduce `set` type

Open anton-trunov opened this issue 7 months ago • 9 comments

It should support the following operations (it's a rough draft, please comment):

  • emptySet(): create an empty set;
  • s.exist(e): returns true if the element e is in the set and false otherwise;
  • s.add(e): modify the set s by adding a new element e to it (we can discuss what this function should return, for instance it can be a boolean signaling if e was already in the set);
  • s.replace(e1, e2): remove e1 and add e2 -- let's discuss the precise semantics or if this is even needed;
  • s1.union(s2): s1 gets extended with the elements of s2 (we might want to also introduce a non-modifying version of this: fun union(s1: set<T>, s2: set<T>): set<T> where T is some "setable" type)
  • s1.intersect(s2): s1 will keep only the elements common between s1 and s2 (the non-modifying version can be also added)
  • ... (set difference, symmetric difference)
  • foreach statement support for sets
  • toCell(), etc.

anton-trunov avatar Jul 15 '24 17:07 anton-trunov