Difference between revisions of "Unique"

Line 1: Line 1:
 
[[Category:Functions that create lists]]
 
[[Category:Functions that create lists]]
 +
[[Category:Array Library]]
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
   
 
   
Returns a maximal subset of I such that each indicated slice of A along I is unique.
+
==Unique(a, i)==
 +
Returns a maximal subset of index «i» such that each indicated [[slice]] of array «a»  along «i»  is unique.
  
= Declaration =
+
[[Unique]] can be used to remove duplicate slices from an array, or to identify a single member of each equivalence class.
  
  Unique(A : Array[I] ; I : Index )
+
== Examples ==
 +
Let
 +
<code>DataSet →</code>
 +
  {| class="wikitable"
 +
!
 +
!colspan="3" | Field ▶
 +
|-
 +
!PersonNum '''▼'''
 +
!LastName
 +
!FirstName
 +
!Company
 +
|-
 +
! scope="row" |1
 +
|Smith
 +
|Bob
 +
|Acme
 +
|-
 +
! scope="row" |2
 +
|Jones
 +
|John
 +
|Acme
 +
|-
 +
! scope="row" |3
 +
|Johnson
 +
|Bob
 +
|Floorworks
 +
|-
 +
! scope="row" |4
 +
|Smith
 +
|Bob
 +
|Acme
 +
|}
  
= When to use:=
+
Then
 +
Unique(DataSet, PersonNum) → [1, 2, 3]
 +
code>Unique(DataSet[Field='Company'], PersonNum) → [1, 3]
  
Use Unique to remove duplicate slices from an array, or to identify a single member of each equivalence class.
+
== Optional parameters ==
 +
=== Position ===
 +
By default, [[Unique]] returns the elements of the index.  Setting the optional parameter «position»  equal ''true'' (<code>position: true</code>) will return the positions of the elements in «i» , rather than the elements themselves (see [[Associative vs. Positional Indexing]]).
  
= See also =
+
===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.
 +
 +
== See also ==
 
* [[SortIndex]]
 
* [[SortIndex]]
 
* [[Subset]]
 
* [[Subset]]

Revision as of 00:59, 21 November 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.

Examples

Let 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]
code>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.

See also

Comments


You are not allowed to post comments.