例:
1 1 1 3 3 4 4 5 5 6 L1
1 3 3 4 5 L2
1 1 4 5 6 Res
限制条件:
(clojure.set/difference)
由于(3)而在这里没有帮助。
(defn diff [s1 s2]
(mapcat
(fn [[x n]] (repeat n x))
(apply merge-with - (map frequencies [s1 s2]))))
例如,给定
(def L1 [1 1 1 3 3 4 4 5 5 6])
(def L2 [1 3 3 4 5 ])
然后
(diff L1 L2)
;(1 1 4 5 6)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句