aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/clojure/clojure/contrib/seq.clj8
-rw-r--r--src/main/clojure/clojure/contrib/seq_utils.clj7
-rw-r--r--src/test/clojure/clojure/contrib/test_seq.clj9
3 files changed, 23 insertions, 1 deletions
diff --git a/src/main/clojure/clojure/contrib/seq.clj b/src/main/clojure/clojure/contrib/seq.clj
index 5b335be5..abac65c0 100644
--- a/src/main/clojure/clojure/contrib/seq.clj
+++ b/src/main/clojure/clojure/contrib/seq.clj
@@ -140,7 +140,13 @@
[pred coll]
(for [[idx elt] (indexed coll) :when (pred elt)] idx))
-
+(defn includes?
+ "Returns true if coll contains something equal (with =) to x,
+ in linear time. Deprecated. prefer 'contains?' for key testing,
+ or 'some' for ad hoc linear searches."
+ {:deprecated true}
+ [coll x]
+ (boolean (some (fn [y] (= y x)) coll)))
diff --git a/src/main/clojure/clojure/contrib/seq_utils.clj b/src/main/clojure/clojure/contrib/seq_utils.clj
index 406f0d3e..018fc2e8 100644
--- a/src/main/clojure/clojure/contrib/seq_utils.clj
+++ b/src/main/clojure/clojure/contrib/seq_utils.clj
@@ -141,6 +141,13 @@
[pred coll]
(for [[idx elt] (indexed coll) :when (pred elt)] idx))
+(defn includes?
+ "Returns true if coll contains something equal (with =) to x,
+ in linear time. Deprecated. Prefer 'contains?' for key testing,
+ or 'some' for ad hoc linear searches."
+ {:deprecated true}
+ [coll x]
+ (boolean (some (fn [y] (= y x)) coll)))
diff --git a/src/test/clojure/clojure/contrib/test_seq.clj b/src/test/clojure/clojure/contrib/test_seq.clj
index 144f7ced..2a7b5ef7 100644
--- a/src/test/clojure/clojure/contrib/test_seq.clj
+++ b/src/test/clojure/clojure/contrib/test_seq.clj
@@ -72,3 +72,12 @@
(deftest test-find-first
(is (= (find-first even? [1 2 3 4 5]) 2))
(is (= (find-first even? '(1 2 3 4 5)) 2)))
+
+(deftest test-includes
+ (are [coll k] (false? (includes? coll k))
+ [1 2 3] 0
+ [] nil
+ [:a :b] :c)
+ (are [coll k] (true? (includes? coll k))
+ [1 2 3] 1
+ [:a :b] :b))