# set

Primitive methods (know about representation)

The representation is a table whose tags are the elements, and

whose values are true.

**member:** *Say whether an element is in a set*

**s**: set

**e**: element

**returns**

**f**: true if e is in set, false otherwise

**insert:** *Insert an element to a set*

**s**: set

**e**: element

**new:** *Make a list into a set*

**l**: list

**returns**

**s**: set

**elements:** *Iterator for sets*

TODO: Make the iterator return only the key

High level methods (representation unknown)

**difference:** *Find the difference of two sets*

**s, t**: sets

**returns**

**r**: s with elements of t removed

**difference:** *Find the symmetric difference of two sets*

**s, t**: sets

**returns**

**r**: elements of s and t that are in s or t but not both

**intersection:** *Find the intersection of two sets*

**s, t**: sets

**returns**

**r**: set intersection of s and t

**union:** *Find the union of two sets*

**s, t**: sets

**returns**

**r**: set union of s and t

**subset:** *Find whether one set is a subset of another*

**s, t**: sets

**returns**

**r**: true if s is a subset of t, false otherwise

**propersubset:** *Find whether one set is a proper subset of*

another

**s, t**: sets

**returns**

**r**: true if s is a proper subset of t, false otherwise

**equal:** *Find whether two sets are equal*

**s, t**: sets

**returns**

**r**: true if sets are equal, false otherwise

## Metamethods for sets

set + table = union

set - table = set difference

set * table = intersection

set / table = symmetric difference

set <= table = subset

set < table = proper subset