Jump to content

Symmetric difference: Difference between revisions

Initial FutureBasic task solution added
(Initial FutureBasic task solution added)
Line 1,431:
A - B : [Serena]
B - A : [Jim]
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
 
local fn SymmetricDifferenceOfSets( setA as CFSetRef, setB as CFSetRef ) as CFSetRef
CFMutableSetRef notInSetA = fn MutableSetWithSet( setB )
MutableSetMinusSet( notInSetA, setA )
CFMutableSetRef notInSetB = fn MutableSetWithSet( setA )
MutableSetMinusSet( notInSetB, setB )
CFMutableSetRef symmetricDifference = fn MutableSetWithSet( notInSetA )
MutableSetUnionSet( symmetricDifference, notInSetB )
end fn = fn SetWithSet( symmetricDifference )
 
CFSetRef set1, set2
 
set1 = fn SetWithObjects( @"John", @"Serena", @"Bob", @"Mary", @"Serena", NULL )
set2 = fn SetWithObjects( @"Jim", @"Mary", @"John", @"Jim", @"Bob", NULL )
 
NSLog( @"Symmetric difference:\n%@", fn SymmetricDifferenceOfSets( set1, set2 ) )
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
Symmetric difference:
{(
Jim,
Serena
)}
</pre>
 
729

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.