1

Clojure 中实现重复的惯用方式是什么?以下:

(duplicates? '( 1 2 3 2)) ; true

做一个:

(not (= (count coll) (count (distinct coll)))

工作量比要求的要多。

4

1 回答 1

4

该函数distinct?已存在于 clojure.core 中,因此您可以使用它:

user=> (not (distinct? 1 2 3 2))
true
user=> (not (distinct? 1 2 3 4))
false
于 2013-02-28T16:54:02.010 回答