Unique: Difference between revisions
Jump to navigation
Jump to search
m
Text replacement - "<code>" to "<source lang=apl inline>"
Miraheze>Marshall |
Miraheze>Adám Brudzewsky m (Text replacement - "<code>" to "<source lang=apl inline>") |
||
Line 64: | Line 64: | ||
== APL model == | == APL model == | ||
For [[Vector|vectors]] the following implementation based on [[Union]] can be used. It repeatedly adds cells of the argument to an accumulated unique vector < | For [[Vector|vectors]] the following implementation based on [[Union]] can be used. It repeatedly adds cells of the argument to an accumulated unique vector <source lang=apl inline>u</code>, using Union so that duplicate cells are never added. | ||
<source lang=apl> | <source lang=apl> | ||
VecUnique ← { | VecUnique ← { | ||
Line 83: | Line 83: | ||
{{Works in|[[Dyalog APL]]}} | {{Works in|[[Dyalog APL]]}} | ||
While the model < | While the model <source lang=apl inline>{((⍳≢⍵)=(⍵⍳⍵))⌿⍵}</code>, based on [[Nub Sieve]], is often described as an implementation of Unique, it does not correctly handle [[tolerant comparison]]. A correct implementation of Nub Sieve could be used to implement Unique, but writing such an implementation is no easier than implementing Unique directly. | ||
== Properties == | == Properties == | ||
Line 99: | Line 99: | ||
* [http://microapl.com/apl_help/ch_020_020_392.htm APLX] | * [http://microapl.com/apl_help/ch_020_020_392.htm APLX] | ||
* [https://www.jsoftware.com/help/dictionary/d221.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/tildedot J NuVoc] (as < | * [https://www.jsoftware.com/help/dictionary/d221.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/tildedot J NuVoc] (as <source lang=apl inline>~.</code>) | ||
{{APL built-ins}} | {{APL built-ins}} |