Login
|
Signup
langref.org
-
ruby
,
erlang
,
csharp
,
fsharp
...
add..
all
clojure
cpp
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 any items of a list
Given a list, test if a certain logical condition (i.e. predicate) holds for any items of the list.
ruby
[2, 3, 4].any? { |x| x > 3 }
[2, 3, 4].any? { |x| x > 3 }
erlang
Result = lists:any(Pred, List).
Result = lists:any(Pred, List).
fsharp
fsharp
let rec IsAny predicate source =
match source with
| [] -> false
| h::t ->
if (predicate h) then true
else (IsAny predicate t )
let rec IsAny predicate source =
match source with
| [] -> false
| h::t ->
if (predicate h) then true
else (IsAny predicate t )
fantom
echo([2,3,4].any{ it==4 })
class SolutionXX
{
Void main()
{
echo([2,3,4].any{ it==4 })
}
}
Submit a new solution for
ruby
,
erlang
,
csharp
,
fsharp
...
There are 9 other solutions in
additional
languages (
clojure
,
cpp
,
groovy
,
haskell
...)