Login
|
Signup
langref.org
-
ruby
,
erlang
,
csharp
, and
fsharp
add..
all
clojure
cpp
fantom
go
groovy
haskell
java
ocaml
perl
php
python
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Lists
Testing
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.
ruby
[2, 3, 4].all? { |x| x > 1 }
[2, 3, 4].all? { |x| x > 1 }
erlang
Result = lists:all(Pred, List).
Result = lists:all(Pred, List).
fsharp
fsharp
let rec IsAll predicate source =
let mutable acc = true
for e in source do
acc <- acc && (predicate e)
acc
let rec IsAll predicate source =
let mutable acc = true
for e in source do
acc <- acc && (predicate e)
acc
Submit a new solution for
ruby
,
erlang
,
csharp
, or
fsharp
There are 9 other solutions in
additional
languages (
clojure
,
cpp
,
fantom
,
groovy
...)