C Library Functions  - unique (3)

NAME

unique(3f) - [M_sets] return unique values in array A

CONTENTS

Synopsis
Description
Options
Returns
Examples
Authors
License

SYNOPSIS

unique(A,setOrder)

DESCRIPTION

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.

OPTIONS

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.

RETURNS

All the values that occur in the input occur in the output just once. All duplicates are removed.

EXAMPLES

sample program:

   program demo_unique
   use M_sets, only: unique
   character(len=*),parameter :: g=’(*(g0,1x))’
   integer,allocatable        :: A(:)

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

Results:

 > 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

AUTHORS

John S. Urban, 2023-07-20

LICENSE

CC0-1.0


Nemo Release 3.1 unique (3) February 23, 2025
Generated by manServer 1.08 from c24277c7-cffb-42f2-a62e-0a77a9ef5f09 using man macros.