Difference between revisions of "Unique"
Line 7: | Line 7: | ||
[[Unique]] can be used to remove duplicate slices from an array, or to identify a single member of each equivalence class. | [[Unique]] can be used to remove duplicate slices from an array, or to identify a single member of each equivalence class. | ||
+ | |||
== Example == | == Example == | ||
Line 51: | Line 52: | ||
<code>[1, 3]</code> | <code>[1, 3]</code> | ||
+ | |||
== Optional parameters == | == Optional parameters == | ||
Line 60: | Line 62: | ||
Specifying ''caseInsensitive: true'' ignores differences in upper and lower case in text values when determining if values are unique. | Specifying ''caseInsensitive: true'' ignores differences in upper and lower case in text values when determining if values are unique. | ||
+ | |||
== See also == | == See also == | ||
* [[SortIndex]] | * [[SortIndex]] | ||
* [[Subset]] | * [[Subset]] |
Revision as of 01:43, 8 December 2015
Unique(a, i)
Returns a maximal subset of index «i» such that each indicated slice of array «a» along «i» is unique.
Unique can be used to remove duplicate slices from an array, or to identify a single member of each equivalence class.
Example
Let:
Variable DataSet :=
Field ▶ | |||
---|---|---|---|
PersonNum ▼ | LastName | FirstName | Company |
1 | Smith | Bob | Acme |
2 | Jones | John | Acme |
3 | Johnson | Bob | Floorworks |
4 | Smith | Bob | Acme |
Then:
Unique(DataSet, PersonNum) →
[1, 2, 3]
Unique(DataSet[Field = 'Company'], PersonNum) →
[1, 3]
Optional parameters
Position
By default, Unique returns the elements of the index. Setting the optional parameter «position» equal true (position: true
) will return the positions of the elements in «i» , rather than the elements themselves (see Associative vs. Positional Indexing).
CaseInsensitive
When applying Unique to text values, values are considered by default in a case-sensitive fashion, for example, "Apple" and "apple" are considered distinct elements.
Specifying caseInsensitive: true ignores differences in upper and lower case in text values when determining if values are unique.
Enable comment auto-refresher