Given a list, test if a certain logical condition (i.e. predicate) holds for any items of the list.
erlang Result = lists:any(Pred, List).
Result = lists:any(Pred, List).
clojure ; The standard library in Clojure has "not-any?" but (oddly enough) no "any?"
(defn any? [pred coll]
((complement not-any?) pred coll))
(any? #(> % 3) [2 3 4])
; The standard library in Clojure has "not-any?" but (oddly enough) no "any?"
(defn any? [pred coll]
((complement not-any?) pred coll))
(any? #(> % 3) [2 3 4])
clojure (some #(> % 3) [2 3 4])
(some #(> % 3) [2 3 4])
Submit a new solution for
php,
erlang,
csharp, or
clojure
There are 10 other solutions in
additional languages (
cpp,
fantom,
fsharp,
groovy ...)