symmetric_difference.lua 389 B

12345678910111213141516171819
  1. A = { ["John"] = true, ["Bob"] = true, ["Mary"] = true, ["Elena"] = true }
  2. B = { ["Jim"] = true, ["Mary"] = true, ["John"] = true, ["Bob"] = true }
  3. A_B = {}
  4. for a in pairs(A) do
  5. if not B[a] then A_B[a] = true end
  6. end
  7. B_A = {}
  8. for b in pairs(B) do
  9. if not A[b] then B_A[b] = true end
  10. end
  11. for a_b in pairs(A_B) do
  12. print( a_b )
  13. end
  14. for b_a in pairs(B_A) do
  15. print( b_a )
  16. end