Symmetric difference: Difference between revisions
Content deleted Content added
→{{header|AppleScript}}: Some simplifications |
m formatting of task description |
||
Line 1: | Line 1: | ||
{{task|Discrete math}} |
{{task|Discrete math}} |
||
⚫ | |||
;Task |
|||
* John |
|||
⚫ | |||
* Bob |
|||
* Mary |
|||
* Serena |
|||
⚫ | |||
and ''B'' contains: |
|||
⚫ | |||
* Jim |
|||
* Mary |
|||
* John |
|||
* Bob |
|||
⚫ | |||
compute |
|||
:<math>(A \setminus B) \cup (B \setminus A).</math> |
|||
;Test cases |
|||
⚫ | |||
A = {John, Bob, Mary, Serena} |
|||
B = {Jim, Mary, John, Bob} |
|||
⚫ | |||
⚫ | |||
;Notes |
;Notes |
||
# If your code uses lists of items to represent sets then ensure duplicate items in lists are correctly handled. For example two lists representing sets of <code>a = ["John", "Serena", "Bob", "Mary", "Serena"]</code> and <code>b = ["Jim", "Mary", "John", "Jim", "Bob"]</code> should produce the result of just two strings: <code>["Serena", "Jim"]</code>, in any order. |
# If your code uses lists of items to represent sets then ensure duplicate items in lists are correctly handled. For example two lists representing sets of <code>a = ["John", "Serena", "Bob", "Mary", "Serena"]</code> and <code>b = ["Jim", "Mary", "John", "Jim", "Bob"]</code> should produce the result of just two strings: <code>["Serena", "Jim"]</code>, in any order. |
||
# In the mathematical notation above <code>A \ B</code> gives the set of items in A that are not in B; <code>A ∪ B</code> gives the set of items in both A and B, (their ''union''); and <code>A ∩ B</code> gives the set of items that are in both A and B (their ''intersection''). |
# In the mathematical notation above <code>A \ B</code> gives the set of items in A that are not in B; <code>A ∪ B</code> gives the set of items in both A and B, (their ''union''); and <code>A ∩ B</code> gives the set of items that are in both A and B (their ''intersection''). |
||
<br><br> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
Ada has the lattice operation '''xor''' predefined on Boolean, modular types, 1D arrays, set implementations from the standard library. The provided solution uses arrays: |
Ada has the lattice operation '''xor''' predefined on Boolean, modular types, 1D arrays, set implementations from the standard library. The provided solution uses arrays: |