Qu

unique

Builtin index · Collections & strings

result = unique(x)

Input: x · Output: result

What it is

x is a numeric Vec.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = unique(x)
x Vecnot documented yet
result Vec
Returns a Vec: a sorted, de-duplicated copy.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

xs = [3, 1, 4, 1, 5, 9, 2, 6]
print(unique(xs))          # [1, 2, 3, 4, 5, 6, 9]

print(sort(xs))            # [1, 1, 2, 3, 4, 5, 6, 9]

print(argsort(xs))         # permutation of indices, ascending

print(sort(xs, true))      # descending

output
[1, 2, 3, 4, 5, 6, 9]
[1, 1, 2, 3, 4, 5, 6, 9]
[1, 3, 6, 0, 2, 4, 7, 5]
[9, 6, 5, 4, 3, 2, 1, 1]

from collections-strings