unique(3f) - [M_sets] return unique values in array A
Synopsis
Description
Options
Returns
Examples
Authors
License
unique(A,setOrder)
unique(3) returns the unique values found in an array. That is, it eliminates all but one occurrence of each value.
The result is in sorted order by default, but may be returned in the order found.
A input array to extract unique values from setOrder May be "sort" or "stable". If "stable" the values are returned in the order discovered. The default is "sorted", which returns the data in ascending order.
All the values that occur in the input occur in the output just once. All duplicates are removed.
sample program:
program demo_unique use M_sets, only: unique character(len=*),parameter :: g=(*(g0,1x)) integer,allocatable :: A(:)Results:write(*,g) UNIQUE,Find the unique elements of vector A. A = [10, -10, 0, 1, 2, 3, 3, 2, 1, -10] write(*,g) A=, A write(*,g) unique(A) write(*,g) unique(A, setOrder=stable)
end program demo_unique
> UNIQUE Find the unique elements of vector A. > A= 10 -10 0 1 2 3 3 2 1 -10 > -10 0 1 2 3 10 > 10 -10 0 1 2 3
John S. Urban, 2023-07-20
CC0-1.0
Nemo Release 3.1 | unique (3) | February 23, 2025 |