Changes for clojure.core/contains?

alex_ndc on Tue, 12 Nov 2013
;; `contains?` is straightforward for maps:
user=> (contains? {:a 1} :a)
true
user=> (contains? {:a nil} :a)
true
user=> (contains? {:a 1} :b)
false


;; It's likely to surprise you for other sequences because it's 
;; about *indices*, not *contents*:

user=> (contains? [:a :b :c] :b)
false

user=> (contains? [:a :b :c] 2)
true

user=> (contains? "f" 0)
true

user=> (contains? "f" 1)
false


;; It can be applied to non-sequences:

user=> (contains? 5 3)
false


;; Although lists are sequences, `contains?` seems to always return
;; `false` for them. (Clojure 1.1)
;;
;; Note, this no longer works in Clojure 1.5, throwing an 
;; IllegalArgumentException.

user=> (contains? '(1 2 3) 1) => false

Phalphalak on Fri, 18 Jan 2013
;; `contains?` is straightforward for maps:
user=> (contains? {:a 1} :a)
true
user=> (contains? {:a nil} :a)
true
user=> (contains? {:a 1} :b)
false


;; It's likely to surprise you for other sequences because it's 
;; about *indices*, not *contents*:

user=> (contains? [:a :b :c] :b)
false

user=> (contains? [:a :b :c] 2)
true

user=> (contains? "f" 0)
true

user=> (contains? "f" 1)
false


;; It can be applied to non-sequences:

user=> (contains? 5 3)
false


;; Although lists are sequences, `contains?` seems to always return
;; `false` for them. (Clojure 1.1)

user=> (contains? '(1 2 3) 1) => false

zkim on Sun, 26 Sep 2010
;; `contains?` is straightforward for maps:
user=> (contains? {:a 1} :a)
true
user=> (contains? {:a 1} :b)
false


;; It's likely to surprise you for other sequences because it's 
;; about *indices*, not *contents*:

user=> (contains? [:a :b :c] :b)
false

user=> (contains? [:a :b :c] 2)
true

user=> (contains? "f" 0)
true

user=> (contains? "f" 1)
false


;; It can be applied to non-sequences:

user=> (contains? 5 3)
false


;; Although lists are sequences, `contains?` seems to always return
;; `false` for them. (Clojure 1.1)

user=> (contains? '(1 2 3) 1) => false

Brian Marick on Sat, 10 Jul 2010
`contains?` is straightforward for maps:
(contains? {:a 1} :a) => true
(contains? {:a 1} :b) => false


It's likely to surprise you for other sequences because it's about *indices*, not *contents*:

(contains? [:a :b :c] :b) => false
(contains? [:a :b :c] 2) => true

(contains? "f" 0) => true
(contains? "f" 1) => false


It can be applied to non-sequences:

(contains? 5 3) => false


Although lists are sequences, `contains?` seems to always return `false` for them. (Clojure 1.1)

(contains? '(1 2 3) 1) => false

Brian Marick on Sat, 10 Jul 2010
`contains?` is straightforward for maps:

(contains? {:a 1} :a) => true
(contains? {:a 1} :b) => false


It's likely to surprise you for other sequences because its about *indices*, not *contents*:


(contains? [:a :b :c] :b) => false
(contains? [:a :b :c] 2) => true

(contains? "f" 0) => true
(contains? "f" 1) => false


It can be applied to non-sequences:


(contains? 5 3) => false


Although lists are sequences, `contains?` seems to always return `false` for them. (Clojure 1.1)


(contains? '(1 2 3) 1) => false