Symmetric difference: Difference between revisions
Content added Content deleted
MaiconSoft (talk | contribs) (Added Delphi example) |
|||
Line 2,528: | Line 2,528: | ||
B \ A: Jim |
B \ A: Jim |
||
Symmetric difference: Serena, Jim</pre> |
Symmetric difference: Serena, Jim</pre> |
||
=={{header|Picat}}== |
|||
Using the ordset module. |
|||
<lang Picat>import ordset. |
|||
go => |
|||
A = ["John", "Serena", "Bob", "Mary", "Serena"].new_ordset(), |
|||
B = ["Jim", "Mary", "John", "Jim", "Bob"].new_ordset(), |
|||
println(symmetric_difference=symmetric_difference(A,B)), |
|||
println(symmetric_difference2=symmetric_difference2(A,B)), |
|||
println(subtractAB=subtract(A,B)), |
|||
println(subtractBA=subtract(B,A)), |
|||
println(union=union(A,B)), |
|||
println(intersection=intersection(A,B)), |
|||
nl. |
|||
symmetric_difference(A,B) = union(subtract(A,B), subtract(B,A)). |
|||
% variant |
|||
symmetric_difference2(A,B) = subtract(union(A,B), intersection(B,A)).</lang> |
|||
{{out}} |
|||
<pre>symmetric_difference = [Jim,Serena] |
|||
symmetric_difference2 = [Jim,Serena] |
|||
subtractAB = [Serena] |
|||
subtractBA = [Jim] |
|||
union = [Bob,Jim,John,Mary,Serena] |
|||
intersection = [Bob,John,Mary]</pre> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |