Symmetric difference: Difference between revisions
Content deleted Content added
Added C#. |
added Fortran |
||
Line 400:
<lang fsharp>> Set.union (Set.difference a b) (Set.difference b a);;
val it : Set<string> = set ["Jim"; "Serena"]</lang>
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
<lang fortran>program Symmetric_difference
implicit none
character(6) :: a(4) = (/ "John ", "Bob ", "Mary ", "Serena" /)
character(6) :: b(4) = (/ "Jim ", "Mary ", "John ", "Bob " /)
integer :: i, j
outer1: do i = 1, size(a)
do j = 1, i-1
if(a(i) == a(j)) cycle outer1 ! Do not check duplicate items
end do
if(.not. any(b == a(i))) write(*,*) a(i)
end do outer1
outer2: do i = 1, size(b)
do j = 1, i-1
if(b(i) == b(j)) cycle outer2 ! Do not check duplicate items
end do
if(.not. any(a == b(i))) write(*,*) b(i)
end do outer2
end program</lang>
Output
<pre>Serena
Jim</pre>
=={{header|GAP}}==
|