Questions tagged [any]

"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.

682 questions
10
votes
4 answers

Python: any() unexpected performance

I am comparing the performance of the any() built-in function with the actual implementation the docs suggest: I am looking for an element greater than 0 in the following list: lst = [0 for _ in range(1000000)] + [1] This is the supposedly…
dabadaba
  • 9,064
  • 21
  • 85
  • 155
10
votes
2 answers

SQLite syntax for operator “ANY”

I'm trying execute this query in SQLite: SELECT * FROM customers WHERE rating = ANY (SELECT rating FROM customers WHERE city = 'Rome'); But received this error: Query Error: near "SELECT": syntax error Unable to execute…
Aksios
  • 103
  • 1
  • 1
  • 7
9
votes
3 answers

Using array.prototype.some inside ngIf

I am developing an angular app using the 8th version. Inside the ngIf expression, I want to check something existanse inside array. So I have written the expression below: *ngIf="questionniare.factors.some(item => item.intensities.length > 0)" But…
ConductedClever
  • 4,175
  • 2
  • 35
  • 69
9
votes
1 answer

Type intersections using any

From https://github.com/Microsoft/TypeScript/pull/3622: Supertype collapsing: A & B is equivalent to A if B is a supertype of A. However: type a = string & any; // Resolves to any, not string!? This intersection resolves to any. Isn't 'any' a…
CRice
  • 29,968
  • 4
  • 57
  • 70
8
votes
2 answers

can you switch over a std::any.type()?

I want to explore how I can use std::any instead of void * or such constructs for message passing. So I created an example code to test this - see below. The use of std::any looks nice, but I want to switch through the types to check which type the…
code_fodder
  • 15,263
  • 17
  • 90
  • 167
8
votes
1 answer

Parallel "any" or "all" in Haskell

A pattern I have come across a number of times now is one where a list of values needs to be checked by mapping some test over it and seeing if any or all of the elements passed. The typical solution is just to use the convenient built-ins all and…
Arcuritech
  • 199
  • 1
  • 4
8
votes
1 answer

Swift Generics vs Any

I read swift documentation in apple site. There is a function swapTwoValues, which swaps two any given values func swapTwoValues1(_ a: inout T, _ b: inout T) { let temporaryA = a a = b b = temporaryA } Now I want to write similar…
Karen Karapetyan
  • 704
  • 1
  • 9
  • 18
8
votes
4 answers

AnyObject vs. Struct (Any)

I would like to create a method like this for my projects: func print(obj: AnyObject) { if let rect = obj as? CGRect { println(NSStringFromCGRect(rect)) } else if let size = obj as? CGSize { …
Paulo Cesar
  • 2,250
  • 1
  • 25
  • 35
8
votes
9 answers

Prolog program to find equality of two lists in any order

I wanted to write a Prolog program to find equality of two lists, where the order of elements doesn't matter. So I wrote the following: del(_, [], []) . del(X, [X|T], T). del(X, [H|T], [H|T1]) :- X \= H, del(X, T, T1). member(X, [X|_]). …
Happy Mittal
  • 3,667
  • 12
  • 44
  • 60
8
votes
2 answers

How to write C function accepting (one) argument of any type

I am implementing simple library for lists in C, and I have a problem with writing find function. I would like my function to accept any type of argument to find, both: find(my_list, 3) and find(my_list, my_int_var_to_find). I already have…
Bartek Chaber
  • 236
  • 1
  • 3
  • 7
7
votes
2 answers

What is the difference between comparable and any?

I have tried to use generics with Go, but I don't really understand when we use any or comparable as type parameter. Can someone help to understand these?
Teguh
  • 81
  • 4
7
votes
2 answers

"Function expression, which lacks return-type annotation, implicitly has an 'any' return type" when adding void operation

I am having a strange issue on TypeScript. I recently learnt about void ... operator because I need to apply it so eslint wouldn't report no-floating-promises. However this particular snippet somehow caused an issue that I cannot reproduce on…
Luke Vo
  • 17,859
  • 21
  • 105
  • 181
7
votes
2 answers

jq: select when any value is in array

Given the input json [ {"title": "first line"}, {"title": "second line"}, {"title": "third line"} ] How can we extract only the titles that contain keywords that are listed in a second "filter" array. Using a shell variable here for…
Bernard
  • 16,149
  • 12
  • 63
  • 66
7
votes
2 answers

Check if any element of Eigen::Matrix is different from zero

I have an Eigen::Matrix, and I need to check if any of its elements is different from 0. I tried the following code: Matrix m; bool f = (m != 0.0).any(); But I got a compiler error. Invalid…
Nick
  • 10,309
  • 21
  • 97
  • 201
7
votes
4 answers

How to create a Map[String,String] from Map[String, Any] in Scala?

New to scala - How to create a Map[String,String] from Map[String, Any] The values of the Map[String,Any] are strings but I don't know how to cast or otherwise coerce the "Any" type to a "String" type.
coolgar
  • 73
  • 1
  • 1
  • 3
1 2
3
45 46