求两个set的交集合,不允许使用Intersection
Write a function which returns the intersection of two sets. The intersection is the sub-set of items that each set has in common.
参考了clojure.set/intersection 的实现
(fn [s1 s2]
(reduce (fn [result item]
(if (contains? s2 item)
result
(disj result item))
) s1 s1)
)
disj 是一个从集合中去除指定项目返回一个新集合的操作