Skip to content

clojure.core/some

View this page on ClojureDocs

Type: function Added: Clojure 1.0 Examples: 15 Runnable: 15
([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)

Examples

by dpritchett on
by devijvers on
by MrHus on
by jamesqiu on
by shockbob on
by shockbob on
by gstamp on
by devn on
by phreed on
by qsys on
by qsys on
by Art-B on
by aviflax on
by humorless on
by JpOnline on

Note by Sgeo

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?
instead.

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.