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
-2
votes
2 answers

python multiline list output and sorting

A query produces multiple lines answer, not always all lines have any output/result, and would produce an empty row [] I want to when any line has a result to be shown and ignore all other empty rows [Case 1] if all rows are empty print out one…
M H
  • 1
  • 3
-2
votes
3 answers

What does any[]=[] datatype mean in TypeScript?

I'm working on a project in a company and there's a variable declared like this chainTypeList: any[]=[]; and I'm not able to access it's values like this. this.chainTypeList.chainTypeCode; It shows this error : Property 'chainTypeCode' does not…
-2
votes
1 answer

How to recover the concrete type from Any

Code: use std::fmt::Debug; use std::any::Any; fn any_to_u16(value: &dyn Any) { let v = value as u16; } fn main() { let x = true; any_to_u16(&x); } Erorr : error[E0606]: casting `&(dyn std::any::Any + 'static)` as `u16` is invalid …
Michał Hanusek
  • 199
  • 3
  • 13
-2
votes
3 answers

Perl Regex for Substituting Any Character

Essentially, I want to replace the u between the random character and the k to be an o. The output I should get from the substitution is dudok and rujok. How can I do this in Perl? I'm very new to Perl so go easy on me. This is what I have right…
Asad
  • 21
  • 4
-2
votes
1 answer

checking for ANY NULL object before ToLower

I have an object where a property may exist or may not exist. if(response.AddressInformation.AddressResponses.Any(inf => inf.AddressResponse.matchCodeStatus.ToLower().Equals("usps_match"))) { } I have two array items of AddressResponse. First item…
Huma Ali
  • 1,759
  • 7
  • 40
  • 66
-2
votes
3 answers

How do I filter strings that start with any vowel? [python]

The string is 'banana'. I have created all substrings and now want to filter those that start or not start with vowels. I want to use any operation but don't know how to use it. l = ['', 'an', 'anan', 'na', 'ana', 'n', 'a', 'anana', 'ba', 'b',…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
-2
votes
1 answer

How to create set a variable in a Struct in swift that conforms to Decodable and Encodable protocol?

I'm fetching data from an API but this API has a small problem inside location JSON Object, it contains a variable called postcode and this variable can be either a String or a Int. I have to handle this problem locally, If I set var postcode:…
Lucas
  • 746
  • 8
  • 23
-2
votes
2 answers

Scala Cast List of Any to list of Int

Given a List of Any: val l = List(2.9940714E7, 2.9931662E7, 2.993162E7, 2.9931625E7, 2.9930708E7, 2.9930708E7, 2.9931477E7) I need to cast each item to Int. Works: l(1).asInstanceOf[Double].toInt Not: l.foreach{_.asInstanceOf[Double].toInt} >…
-2
votes
1 answer

Look for any characters in PHP switch cases

I need to have a case that checks for a few first characters, and then accept any other 7 characters. Something like this: DN98??????? I tried doing it like this: case 'DN98'+'[a-zA-Z0-9]': $theme = 'correct-page'; …
fenbekus
  • 3
  • 1
-2
votes
2 answers

How to assign a value to [any]

When I set c to a var a: [Any] var c: Array error shown: cannot convert value of type 'Array' to expected argument type [Any] how to solve the problem?
leo_luck
  • 151
  • 2
  • 8
-2
votes
4 answers

Python - any base to decimal (other2dec)

I failed an exam because of one question. The task is: "Design a program that converts any number from any system to decimal. We confine to the systems in the range from 2 to 22." So there I am. I know the binary[2], octal[8], decimal[10] and…
Tom Wojcik
  • 5,471
  • 4
  • 32
  • 44
-3
votes
2 answers

any() function not producing expected result

I have encountered a problem while testing my code in python. I have a list of floats in my code, one of the items is greater then 1. So, the aaa[1]>1 results in True. When I try the any(aaa)>1, I get False. Could you please elaborate on the…
amgh
  • 1
-3
votes
2 answers

Is there a way to return the index of an element that returns True in the any() function?

(This is just an example of what I'd like to be solved) array = ["hello", "hi"] statement = input() condition = any(statement in elm for elm in array) Is there a way to return the index of the element that returns True, or should I just use a for…
-3
votes
1 answer

How to check if the condition is true at least once in Python?

Let's say I have several lists. If the number 1 appears at least once, I want to return it as True. If there are no instances of 1 appearing, then it is False. So let's say I have several lists. [2.0,2.0] [1.0, 1.0, 2.0, 2.0] [1.0, 2.0] [3.0,…
Gian Batayola
  • 73
  • 1
  • 11
-3
votes
1 answer

When finding and using a single result in Iinq using ToArray() huge performance increase

I had some code for processing XML file that was running pretty slowly. The offending code is below. The first query should get either zero or one record from a set of about 1,000 records. If I get one, I then pull from another set (holding about…
patrickL
  • 23
  • 4
1 2 3
45
46