@lang:unique
Remove duplicates from an array, preserving first-occurrence order.
On-chain (@lang:unique!): Removes adjacent duplicates only; nest @sort! for set-uniqueness.
Returns: array
Syntax
Section titled “Syntax”@lang:unique(arr)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
arr | array | Source array |
See Also
Section titled “See Also”- @filter — custom duplicate removal
On-chain face (@unique!)
Section titled “On-chain face (@unique!)”Deduplicate ADJACENT equal words of the array return of a call on-chain
through uniqueWords (O(n)). For set-uniqueness over unsorted input,
nest @sort!: @unique!(@sort!(…)).
Examples
Section titled “Examples”load lang
set $safe 0x44fA8E6f47987339850636F88629646662444217
assert @unique!(@sort!($safe::{getOwners()(address[])})) == 0x1122See Also
Section titled “See Also”assert,@sort!