Clojure: Testing every value from map operation for truth
Posted
by
Ralph
on Stack Overflow
See other posts from Stack Overflow
or by Ralph
Published on 2010-12-31T17:10:49Z
Indexed on
2011/01/01
13:53 UTC
Read the original article
Hit count: 280
How can I test that every value in the collection returned by map
is true
?
I am using the following:
(defn test [f coll]
(every? #(identity %) (map f coll)))
with the anonymous function #(identity %)
, but I was wondering if there is a better way.
I cannot use (apply and ...)
because and
is a macro.
UPDATE: BTW, I am making my way through The Haskell Road to Logic, Maths, and Programming, by Kees Doets and Jan can Eijck, but doing the exercises in Clojure. It's a very interesting book.
© Stack Overflow or respective owner