Quick actions

cmd+k|ctrl+k

Navigation

Languages

array_XOR

Snippet info

Language

Julia

Visibility

public

Author

jenkuo.chang

Created

2019-12-17T09:03:13Z

Updated

2019-12-18T09:36:26Z

#https://stackoverflow.com/questions/47985297/how-to-xor-two-lists-in-python/47985302
println("julia ver.: ", VERSION)
a_list = ["hello", "world"]
b_list = ["hello", "world", "1.one", "2.two"]
c_list = String[]

c_list = append!(c_list, a_list)
c_list = append!(c_list, b_list)
println("List a= ", a_list)
println("List b= ", b_list)
println("a + b = ", c_list)

ans_list = String[]
for item in c_list
    if !(item ∈ a_list) || !(item ∈ b_list)
        push!(ans_list, item)
    end
end
println("\nAns: ", ans_list)
INFO