Sets

Sets

> LeekScript

A set is a structure for storing distinct values. Unlike a list, the elements are unique, but like a table they are not ordered.

Creation

You can create a set with the following syntax:

A set can contain any type of value:

Reading

Searching for an element takes place in constant time:

The in operator can also be used:

Modification

Add an element :

Deleting an element:

Operations

Possible operations on sets are union, intersection, difference and disjunction:

Iteration

It is possible to iterate over the elements of a set, without the order being determined: