我如何使用Clojure的独特之处?集合上的功能?

Rob*_*ell 8 clojure

Clojure 与众不同?方法不采用集合,而是采用args列表

(distinct? x)
(distinct? x y)
(distinct? x y & more)
Run Code Online (Sandbox Code Playgroud)

因此(distinct?0 0 0 0)正确返回false,而(distinct?[0 0 0 0])返回true.我该如何使用不同的?在一个集合上,以便传递一个集合[0 0 0 0]将返回false,因为该集合包含重复项?

我确实意识到该函数正在正常运行,但我正在寻找一种技巧来将它应用于集合的内容而不是args列表.

作为一种解决方法,我目前有

(defn coll-distinct? [coll]
   (= (distinct coll) coll))
Run Code Online (Sandbox Code Playgroud)

但我觉得我错过了一种更优雅的方式重复使用

Mik*_*las 17

如果要将参数作为seq传递给函数,请使用apply.

(apply distinct? [1 2 3 1])
; false
(apply distinct? [1 2 3])
; true
Run Code Online (Sandbox Code Playgroud)