• clojure
• java

# some

## clojure.core

• (some pred coll)
Returns the first logical true value of (pred x) for any x in coll,
else nil. One common idiom is to use a set as pred, for example
this will return :fred if :fred is in the sequence, otherwise nil:
(some #{:fred} coll)

### 8 Examples top

• ```user=> (some even? '(1 2 3 4))
true
user=> (some even? '(1 3 5 7))
nil```
• ```user=> (some true? [false false false])
nil
user=> (some true? [false true false])
true
user=> (some true? [true true true])
true
```
• ```user=> (some #(= 5 %) [1 2 3 4 5])
true
user=> (some #(= 5 %) [6 7 8 9 10])
nil```
• ```user=> (some #(when (even? %) %) '(1 2 3 4))
2```
• ```user=> (some {2 "two" 3 "three"} [nil 3 2])
"three"```
• ```;; some can be used as a substitute for (first (filter ...
;; in most cases

user=> (first (filter even? [1 2 3 4]))
2
user=> (some #(if (even? %) %) [1 2 3 4])
2
user=>```
• ```;; find a whether a word is in a list of words.
(def word "foo")
(some (partial = word) words)```
• ```user=> (some #{2} (range 0 10))
2

user=> (some #{200} (range 0 10))
nil```

### Source clojure/core.clj:2379 top

```(defn some
"Returns the first logical true value of (pred x) for any x in coll,
else nil.  One common idiom is to use a set as pred, for example
this will return :fred if :fred is in the sequence, otherwise nil:
(some #{:fred} coll)"
:static true}
[pred coll]
(when (seq coll)
(or (pred (first coll)) (recur pred (next coll)))))```
Vars in clojure.core/some:
Used in 0 other vars

#### 1 comment(s) for some.

Be careful about using sets as predicates if you don't know what is in the set. In particular,

`(#{nil} nil)`
is
`nil`
and
`(#{false} false)`
is
`false`
Consider using
`contains?`