# Functions introduction

Set functions are used to inspect and manipulate sets of domains.

Some functions return new sets, others return Boolean or numerical values. For example, the `CLONE` function returns a new set that is an exact copy of an existing set:

``````var copyOfAll;

copyOfAll = CLONE(ALL);
``````

Meanwhile, the `EMPTY` function checks if a set is empty, returning a Boolean value.

``````var copyOfAll;

copyOfAll = CLONE(ALL);

if (EMPTY(copyOfAll)) {
...
}
``````

Set functions can be used:

• To give a value to set variables.
• As arguments of other functions.
• In complex expressions.

This is another example using Boolean functions in a complex Boolean expression:

``````RESULTS = CLONE(ALL);
if (EXIST(RESULTS, "98.06.") && !EXIST(RESULTS, "98.07.") && !EXIST(RESULTS, "98.08."))
{
INSERT(RESULTS, "03.01.03.");
TRANSFORM("03.01.03.", "98.06.");
REMOVE(RESULTS, "98.06.");
}
WINNERS = CLONE(RESULTS);
``````

The code above replaces category `98.06.` with category `03.01.03.` if the result set includes category `98.06.` but does not include categories `98.07.` and `98.08.`.

The available functions are listed in the following table and are described in the next pages of this section.

Warning

Don't create new global functions with the same name (case sensitive) of those listed below.

Function Use
`ADD` Add points to the score of a domain
`CHANGESCORE` Set a score for a domain
`CLAN` Get domains from the project's taxonomy
`CLEAN` Filter domains based on their score
`CLONE` Copy a set
`DIFFERENCE` Subtract a set from another
`DIMENSIONS` Check the size of a set
`DIVIDE` Divide the score of a domain by a specified value
`EMPTY` Check if a set is empty
`EXIST` Check if a set contains a domain
`EXTRACT` Check if a set contains domains in a list
`EXTRACTSCORE` Get the score of one or more domains in a set
`EXTRACT2` Get a portion of a set based on position
`FAMILY` Get a portion of a set based on project's taxonomy
`FILTER` Get a portion of a set based on relative ranking
`FIRST` Get the top ranking domain
`INSERT` Add new domains to a set (with or without a starting score)
`INTERSECTION` Get the domains that two sets have in common
`LENGTH` Get the number of domains in a set
`MULTIPLY` Multiply the score of domains by a value
`RATIO` Compare the score of two domains or two sets
`RATIO2` Compare the score of a domain or set with a fraction of the score of another domain/set
`REMOVE` Remove a domain from a set
`SCORED` Get a domain based on its ranking
`SECOND` Return the domain with the second highest score
`SET` Create a new set from scratch
`SUBTRACT` Subtract points to the score of a domain
`THRESHOLD` Filter set domains based on a comparison with the score of a given domain
`THRESHOLD2` Filter set domains based on a comparison with a fraction of the score of a given domain
`TRANSFORM` Transfer scores and rule information among domains
`UNION` Add a set to another