I'm trying to create a union of two sets with no duplications. Array a contains n distinct integers. Array b contains m distinct integers. I want to find out the number of elements in the union before I place elements into the union array, so that I can allocate memory. Anyway, I want to count the number of elements in a that aren't in b as follows:
p=0
do i=1,n,1
if (a(i) /= b(j) for j = 1,..., & m) then
!i.e. a(i) /= b(1) .and. a(i) /= b(2) .and. ... a(i) /= b(m)
p = p+1
end if
end do
The problem is that I don't know how to code the above conditional statement so that it recognizes only elements of a that aren't in b. What kind of construct would work?
p=0
do i=1,n,1
if (a(i) /= b(j) for j = 1,..., & m) then
!i.e. a(i) /= b(1) .and. a(i) /= b(2) .and. ... a(i) /= b(m)
p = p+1
end if
end do
The problem is that I don't know how to code the above conditional statement so that it recognizes only elements of a that aren't in b. What kind of construct would work?