I want to apply a series of tests on my list and make sure that all the tests are passed. Is there a function similar to "andmap" in Clojure?
A:
(every? will ask "does this one function return true for each memeber of the seq, which is close to what I think you are asking for. An improvement on every? would take a list of functions and ask "are all these predicates true for every member of this seq"
here is a first attempt:
(defn andmap? [data tests]
(every? true?
(map (fn [test] (every? true? (map (fn [data] (test data)) data)))
tests)))
>(andmap? '(2 4 8) [even? pos?])
true
>(andmap? '(2 4 8) [even? odd?])
false
Arthur Ulfeldt
2009-07-30 23:41:38
A:
Jonas
2009-07-31 03:41:31