Unique: Difference between revisions

Jump to navigation Jump to search
1 byte removed ,  14:48, 20 November 2019
m
12 revisions imported: Migrate from miraheze
Miraheze>Adám Brudzewsky
No edit summary
m (12 revisions imported: Migrate from miraheze)
(3 intermediate revisions by 2 users not shown)
Line 15: Line 15:
└───┴───┴────┘
└───┴───┴────┘
</source>
</source>
In some languages, such as [[Dyalog APL]] and [[J]], Unique applies to the [[major cells]] of an array, including those with rank greater than 1:
In some languages, such as [[J]] and [[Dyalog APL 17.0]] and later, Unique applies to the [[major cells]] of an array, including those with rank greater than 1:
<source lang=apl>
<source lang=apl>
       ⊢x ← (⍳10)∘.∨2 3 6
       ⊢x ← (⍳10)∘.∨2 3 6
Line 41: Line 41:
To construct the Unique of an array, the major cells are considered in order of increasing [[index]]. Each cell is included if it does not [[match]] any cell which was already included.
To construct the Unique of an array, the major cells are considered in order of increasing [[index]]. Each cell is included if it does not [[match]] any cell which was already included.


The array matching is subject to [[tolerant comparison]]. In the intolerant case, that is, when equality is [https://en.wikipedia.org/wiki/Transitive_relation transitive], a cell is included if and only if it does not match any other cell which appears earlier in the array. That's because all the discarded duplicate cells must have matched an earlier included cell; if equality is transitive then a cell which matches the duplicate would also match the earlier cell.
The array matching is subject to [[tolerant comparison]]. In the intolerant case, that is, when equality is [[wikipedia:Transitive_relation|transitive]], a cell is included if and only if it does not match any other cell which appears earlier in the array. That's because all the discarded duplicate cells must have matched an earlier included cell; if equality is transitive then a cell which matches the duplicate would also match the earlier cell.


=== Tolerant comparison ===
=== Tolerant comparison ===
Line 95: Line 95:
=== Documentation ===
=== Documentation ===


* [http://help.dyalog.com/latest/Content/Language/Primitive%20Functions/Unique.htm Dyalog]
* [http://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Unique.htm Dyalog]


* [http://microapl.com/apl_help/ch_020_020_392.htm APLX]
* [http://microapl.com/apl_help/ch_020_020_392.htm APLX]

Navigation menu