弑天下
并 = function(A, B) { d = {} set = [] for (k in A) { if (!(A[k] in d)){set.push(A[k])} d[A[k]] = k } for (k in B) { if (!(B[k] in d)){set.push(B[k])} d[B[k]] = k } return set}交 = function(A, B) { d = {} set = [] for (k in A) { d[A[k]] = k } for (k in B) { if (B[k] in d){set.push(B[k])} d[B[k]] = k } return set}差 = function(A, B) { d = {} set = [] for (k in B) { d[B[k]] = k } for (k in A) { if (!(A[k] in d)){set.push(A[k])} d[A[k]] = k } return set}补 = function(A, B) { return 差(B, A)}> 并([1,2],[1,3,5])[ 1, 2, 3, 5 ]> 差([1,2],[1,3,5])[ 2 ]> 交([1,2],[1,3,5])[ 1 ]> 补([1,2],[1,3,5])[ 3, 5 ]>