C Library Functions  - intersect (3)

NAME

intersect(3f) - [M_sets] Find the values common to both sets A and B

CONTENTS

Synopsis
Description
Options
Examples
Authors
License

SYNOPSIS

intersect(A,B, setOrder)

DESCRIPTION

The values that occur at least once in each set are returned.

That is, intersect(3f) returns the data common to both A and B, with no repetitions.

OPTIONS

A input array
B input array
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.

EXAMPLES

sample program:

  program demo_intersect
  use M_sets, only: unique, intersect, union, setdiff, ismember, setxor
  character(len=*),parameter :: g=’(*(g0,1x))’
  integer, allocatable       :: A(:)
  integer, allocatable       :: B(:)

write(*,g) ’INTERSECT’, ’Find the values common to both A and B.’ A=[7, 1, 7, 7, 4] B=[7, 0, 4, 4, 0] write(*,g) ’A=’, A write(*,g) ’B=’, B write(*,g) intersect(A, B) write(*,g) intersect(A, B, setOrder=’stable’) end program demo_intersect

Results:

 > INTERSECT Find the values common to both A and B.
 > A= 7 1 7 7 4
 > B= 7 0 4 4 0
 > 4 7
 > 7 4

AUTHORS

John S. Urban, 2023-07-20

LICENSE

CC0-1.0


Nemo Release 3.1 intersect (3) June 29, 2025
Generated by manServer 1.08 from 429a63b8-9f8f-49a0-aa42-b0f5f05cd3ad using man macros.