View Problem

Test if a condition holds for all items of a list

Given a list, test if a certain logical condition (i.e. predicate) holds for all items of the list.
DiskEdit
ruby
[2, 3, 4].all? { |x| x > 1 }
DiskEdit
clojure
(every? #(> % 1) [2 3 4])
ExpandDiskEdit
cpp boost
template <typename InputIterator, typename Predicate>
bool match_all(InputIterator first, InputIterator last, Predicate pred)
{
return find_if(first, last, !pred(_1)) == last;
}
DiskEdit
erlang
Result = lists:all(Pred, List).

Submit a new solution for ruby, clojure, cpp, or erlang
There are 8 other solutions in additional languages (fantom, fsharp, groovy, haskell ...)