"Any" means "at least one". Use this tag for questions that deal with testing elements in a collection to see if at least one of them passes a condition.
Questions tagged [any]
682 questions
4
votes
1 answer
Implementing function to detect if a number is prime using any() in R
Was exploring ways to avoid the for loop and instead make use of the any() function to implement a function that gives true when the passed argument is prime and false other wise.
Here is what I have:
prime2 <- function(n) {
rangeOfNumbers <-…

Siddharth-Soni
- 120
- 7
4
votes
5 answers
Filter rows which has at least one of particular values
I have a data frame like this.
df
Tour Order Machine Company
[1] A D D B
[2] B B A G
[3] A E B A
[4] C B C B
[5] A G …

Makoto Miyazaki
- 1,743
- 2
- 23
- 39
4
votes
1 answer
What is the difference between [String: AnyObject] and [String: Any]?
I usually use [String: AnyObject]. But I noticed that Alamofire uses [String: Any]. I read somewhere that Any is "superior" than AnyObject or "encompasses" AnyObject. But other than that, I don't know if there's any different between them. Is there…

Chen Li Yong
- 5,459
- 8
- 58
- 124
4
votes
6 answers
python: return False if there is not an element in a list starting with 'p='
having a list like
lst = ['hello', 'stack', 'overflow', 'friends']
how can i do something like:
if there is not an element in lst starting with 'p=' return False else return True
?
i was thinking something like:
for i in lst:
if…

91DarioDev
- 1,612
- 1
- 14
- 31
4
votes
1 answer
Swift 3 array indexOf function is missing
When I try to print index of the array which contains any object. It's not suggesting the indexOf function. When I try to enter manually its shows error that I have attached screenshot.
But it's working for Array of String. Can anyone please help…

Mani murugan
- 1,792
- 2
- 17
- 32
4
votes
1 answer
Haskell/GHC performance of `any`/`all`
I wrote quantification functions exists, forall, and none for Haskell's build-in [] list data type. On multiple occasions, these seemed to prove much more efficient than Prelude/Data.Lists any and all. I naively suspect that this performance is due…
user6428287
4
votes
0 answers
Why is 'all' and 'any' not implemented as a chain of 'and' and 'or's?
I was wondering if it was discussed - when designing Python - whether all and any should be implemented as a chain of and and ors respectively? And what was the rationale not to do so.
Right now all and any are implemented equivalently to:
def…

Willem Van Onsem
- 443,496
- 30
- 428
- 555
4
votes
6 answers
How to perform logical operations OR on list [multiple elements]?
Is there any way to compare the list elements and return the outcome value ?
Below is the python snippet, where it recieves two values and returns the value.
def logical_or_decision(a,b):
return a or b
value = logical_or_decision(1,0)
print…

Jackie
- 129
- 17
4
votes
4 answers
Using List.Any() to find if a string contains an item as well as find the matching item?
I have a list of strings, which can be considered 'filters'.
For example:
List filters = new List();
filters.Add("Apple");
filters.Add("Orange");
filters.Add("Banana");
I have another list of strings, which contains…

Sach
- 10,091
- 8
- 47
- 84
4
votes
2 answers
How do I check if a string exists within a string within a column
What I want to do I figured would look like this:
(t in df[self.target]).any()
But I am getting:
AttributeError: 'bool' object has no attribute 'any'

birdmw
- 865
- 10
- 18
4
votes
1 answer
Subquery with "ANY" and local array generate nested too deep SQL Statement
public IEnumerable GetMatchingTable1(string param, double[] Thicknesses)
{
return DBContext.Table1.Where(c => c.Field1 == param
&& Thicknesses.Any(Thickness => Thickness >= c.MinThickness && Thickness…

AXMIM
- 2,424
- 1
- 20
- 38
4
votes
2 answers
How to Create an Expression tree for .Where(x => x..Select(y => y.id).Intersect(List).Any())
I'm creating a method that receives a Queryable source, a string with a property name/path (could be a deep property for example "TrParent.DataTypes" to achieve this x => x.TrParent.DataTypes) and Enumerable which holds the values I need to…

c0y0teX
- 1,462
- 1
- 23
- 25
4
votes
1 answer
C++ Error C2228 (left of '.val' must have class/struct/union) in unusual circumstances
In C++, I am trying to implement my own any class using C++. However, before I was able to test it (so if my implementation is bad, feel free to correct me), I got the error: error C2228: left of '.val' must have class/struct/union twice from using…

Joe
- 1,059
- 2
- 11
- 21
4
votes
3 answers
SQL - Find the grade of students who only like students in the same grade
I am doind a free Stanford online course (which is pretty cool, you should check that out) and I've been racking my brains for the lest 2 days and can't find an answer to the following problem. Please help.
Question 4
Find names and grades of…

Cesar Zapata
- 196
- 1
- 7
- 15
4
votes
2 answers
postgresql: any on subquery returning array
I have a user_lists table that contains a user_list column of type integer[].
I'm trying to do this query, which seems basic enough:
select id, alias from users where id = ANY(select user_list from user_lists where id = 2 limit 1);
It gives this…

Ty Kroll
- 1,385
- 12
- 27