# EXTRACT and EXTRACT2

## EXTRACT

The `EXTRACT` function returns a new set containing the domains of an existing set matching a list of domains.

For example, if `workingSet` has these contents from the sample taxonomy in the introduction:

``````1   Sport
1.01    martial art
1.15    rugby
1.17    skiing
1.18    tennis
``````

this statement:

``````var checked = EXTRACT(workingSet, ["1.01", "1.02"]);
``````

will define and populate the `checked` set in this way:

``````1.01
``````

because `1.01` is the only domain of the list on the right that is present in `workingSet`.

The syntax is:

`EXTRACT(set, domain)`

Or:

`EXTRACT(set, [domains])`

where:

• `set` is a set variable.
• `domain` is the domain name or ID.
• `domains` is a comma-separated list of domain IDs. Each domain name must be enclosed in quotation marks. `domain` or `domains` are searched for in `set` and the function returns a new set containing the domains that are found.

## EXTRACT2

The `EXTRACT2` function returns a new set containing a given consecutive domains numbers included in it starting from a certain position in the ranking.

For example, if `workingSet` has these contents from the sample taxonomy in the introduction:

``````1   Sport
1.01    martial art
1.15    rugby
1.17    skiing
1.18    tennis
``````

this statement:

``````var topTwo = EXTRACT2(workingSet, 2, 1);
``````

will define and populate the `topTwo` set in this way:

``````1
1.01
``````

because `1` occupies position one (third argument of the function) inside `workingSet`, `1.01` is next to it and two (second argument of the functions) domains are required.

### Domain positions in a set

`EXTRACT2` is the only set function that takes into account the order of domains and their respective rankings from highest to lowest scoring within a set. All other functions are indifferent to these features. In fact, domains inside a set have positions that derive from the way the set is populated.

The domains inside the predefined set `ALL` have positions reflecting their score, ranked from highest to lowest, inside the hidden results table. Because the domains are listed depending on their scores, as the scores decrease, the number associated with the position will increase. Note that, domains that receive the same score will have consecutive positions, but it will not be known in advance which domain will come first.

When the `CLONE` function is used to create an exact copy of a set, the position of the domains inside the copy will be the same as the original set.

When a new set is created with the `SET` function, domains inside the resulting set have positions reflecting the order in which they are listed in the list argument of the `SET` call.

Domains added with the `INSERT` function are appended to the destination set, so they occupy the last positions inside it.

### Syntax

The `EXTRACT2` syntax is:

`EXTRACT2(set, count, position)`

where:

• `set` is a set variable.
• `count` is the number of consecutive domains to consider.
• `position` is the position of the first domain to consider.