symmetric_difference.lua 411 B

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