contains

Selectively disable subsumption in Scala? (correctly type List.contains)

最后都变了- 提交于 2019-11-30 07:21:28
问题 List("a").contains(5) Because an Int can never be contained in a list of String , this should generate an error at compile-time , but it does not. It wastefully and silently tests every String contained in the list for equality to 5 , which can never be true ( "5" never equals 5 in Scala). This has been named "the 'contains' problem". And some have implied that if a type system cannot correctly type such semantics, then why go through the extra effort for enforcing types. So I consider it is

How to check if an array contains a particular string?

旧时模样 提交于 2019-11-30 06:55:51
I have an array of strings. I want to check if a particular string is present in the array. DECLARE TYPE v_array IS TABLE OF VARCHAR2(200); ais_array v_array; BEGIN ais_array := ('Lb1','Lb2','Lb3','Lb613'); IF 'Lb1' IN ais_array THEN dbms_output.put_line('found'); END IF; END; The IN operator is not working. I tried doing a select * on the type and then using IN but that didn't work either. Any suggestions? Egor Skriptunoff Try member of condition: IF 'Lb1' member of ais_array THEN dbms_output.put_line('found'); END IF; Oracle introduced several set operators for working with collections in

How to use Linq to check if a list of strings contains any string in a list

≡放荡痞女 提交于 2019-11-30 06:46:22
I'm constructing a linq query that will check is a string in the DB contains any of the strings in a list of strings. Something like. query = query.Where(x => x.tags .Contains(--any of the items in my list of strings--)); I'd also like to know how many of the items in the list were matched. Any help would be appreciated. Update: I should have mentioned that tags is a string not a list. And I am adding on a couple more wheres that are not related to tags before the query actually runs. This is running against entity framework. EDIT: This answer assumed that tags was a collection of strings...

XPath with multiple contains on different elements

谁说胖子不能爱 提交于 2019-11-30 03:17:32
问题 Is it possible to have XPath expression with multiple contains of different element values? XML <data> <person> <firstname>Kerry</firstname> <lastname>Packer</lastname> <address>Crown</address> <person> <person> <firstname>Kerry</firstname> <lastname>Murdoch</lastname> <address>California</address> <person> <data> PHP $xml = simplexml_load_string($data); $elements = $xml->xpath("(//person)[firstname[contains(., 'Kerr')]] and [lastname[contains(., 'och')]]"); Currently above XPath expression

Finding Points contained in a Path in Android

╄→гoц情女王★ 提交于 2019-11-29 21:08:23
Is there a reason that they decided not to add the contains method (for Path) in Android? I'm wanting to know what points I have in a Path and hoped it was easier than seen here: How can I tell if a closed path contains a given point? Would it be better for me to create an ArrayList and add the integers into the array? (I only check the points once in a control statement) Ie. if(myPath.contains(x,y) So far my options are: Using a Region Using an ArrayList Extending the Class Your suggestion I'm just looking for the most efficient way I should go about this I came up against this same problem a

xpath: find a node that has a given attribute whose value contains a string

强颜欢笑 提交于 2019-11-29 20:32:54
Is there an xpath way to find a node that has a given attribute whose value contains a given string? For example I have an xml document and want to find a node where the address attribute contains the string Downing , so that I could find the following node: <person name="blair" address="10 Downing St. London"/> select="//*[contains(@address,'Downing')]" 来源: https://stackoverflow.com/questions/614797/xpath-find-a-node-that-has-a-given-attribute-whose-value-contains-a-string

How to check if a table contains an element in Lua?

折月煮酒 提交于 2019-11-29 19:41:07
Is there a method for checking if a table contains a value ? I have my own (naive) function, but I was wondering if something "official" exists for that ? Or something more efficient... function table.contains(table, element) for _, value in pairs(table) do if value == element then return true end end return false end By the way, the main reason I'm using this functions is to use tables as sets, ie with no duplicate elements. Is there something else I could use ? interjay You can put the values as the table's keys. For example: function addToSet(set, key) set[key] = true end function

how to check if List<T> element contains an item with a Particular Property Value

[亡魂溺海] 提交于 2019-11-29 19:29:36
public class PricePublicModel { public PricePublicModel() { } public int PriceGroupID { get; set; } public double Size { get; set; } public double Size2 { get; set; } public int[] PrintType { get; set; } public double[] Price { get; set; } } List<PricePublicModel> pricePublicList = new List<PricePublicModel>(); How to check if element of pricePublicList contains certain value. To be more precise, I want to check if there exists pricePublicModel.Size == 200 ? Also, if this element exists, how to know which one it is? EDIT If Dictionary is more suitable for this then I could use Dictionary, but

Wildcard query expansion resulted in too many terms

非 Y 不嫁゛ 提交于 2019-11-29 18:03:31
I am receiving a "wildcard query expansion resulted in too many terms" error when executing a query similar to the following: SELECT * FROM table_a WHERE contains(clob_field, '%a%') > 0; Does anyone know a workaround/solution to this problem? According to this , you may need to increase the wildcard_maxterms parameter, or take further steps. See the link for details (I'm not an expert in Oracle Text though). 来源: https://stackoverflow.com/questions/2554054/wildcard-query-expansion-resulted-in-too-many-terms

Determine if all characters in a string are the same

ぐ巨炮叔叔 提交于 2019-11-29 17:00:57
问题 I have a situation where I need to try and filter out fake SSN numbers. From what I've seen so far if they are fake they're all the same number or 123456789. I can filter for the last one, but is there an easy way to determine if all the characters are the same? 回答1: return (ssn.Distinct().Count() == 1) 回答2: This method should do the trick: public static bool AreAllCharactersSame(string s) { return s.Length == 0 || s.All(ch => ch == s[0]); } Explanation: if a string's length is 0, then of