list
mysql check if numbers are in a comma separated list
This one also works: SELECT * FROM table WHERE 3 IN (NUMBERS) AND 15 IN (NUMBERS) using the IN will look into a comma separated string eg. these two WHERE banana IN (‘apple’, ‘banana’, ‘coconut’) WHERE 3 IN (2,3,6,8,90) Info found on this page:
Transpose a matrix in Python [duplicate]
You can use zip with * to get transpose of a matrix: >>> A = [[ 1, 2, 3],[ 4, 5, 6]] >>> zip(*A) [(1, 4), (2, 5), (3, 6)] >>> lis = [[1,2,3], … [4,5,6], … [7,8,9]] >>> zip(*lis) [(1, 4, 7), (2, 5, 8), (3, 6, 9)] If you want the returned list … Read more
Merging two lists in Haskell
I want to propose a lazier version of merge: merge [] ys = ys merge (x:xs) ys = x:merge ys xs For one example use case you can check a recent SO question about lazy generation of combinations. The version in the accepted answer is unnecessarily strict in the second argument and that’s what is … Read more
conditional Updating a list using LINQ
cleaner way to do this is using foreach foreach(var item in li.Where(w => w.name ==”di”)) { item.age=10; }
Is there a Kotlin equivalent of Java’s Collections.synchronizedList ? Or is this not needed in Kotlin
If I try to use the Java List a warning message comes up “This class shouldn’t be used in Kotlin…” Java lists (and other collections) are mapped types in Kotlin. So you can use Collections.synchronizedList, and it takes and returns a Kotlin List or MutableList. OTOH, synchronizedList is rarely what you actually want: it works … Read more
Issue warning for missing comma between list items bug
These are merely probable solutions since I’m not really apt with static-analysis. With tokenize: I recently fiddled around with tokenizing python code and I believe it has all the information needed to perform these kind of checks when sufficient logic is added. For your given list, the tokens generated with python -m tokenize list1.py are … Read more
Static typing in python3: list vs List [duplicate]
Not all lists are the same from a typing perspective. The program def f(some_list: list): return [i+2 for i in some_list] f([‘a’, ‘b’, ‘c’]) won’t fail a static type checker, even though it won’t run. By contrast, you can specify the contents of the list using the abstract types from typing def f(some_list: List[int]) -> … Read more
Complexity of std::list::splice and other list containers
This was a very contentious topic during the standardization of C++11. The problem is that all standard containers, including lists, also have a constant-time size operation. Before C++11, many implementations made size linear time and splice between different lists constant time. C++11 now requires that size be constant and splice be linear. The problem is … Read more
set list as value in a column of a pandas dataframe
You’d have to do: df[‘new_col’] = [my_list] * len(df) Example: In [13]: df = pd.DataFrame(np.random.randn(5,3), columns=list(‘abc’)) df Out[13]: a b c 0 -0.010414 1.859791 0.184692 1 -0.818050 -0.287306 -1.390080 2 -0.054434 0.106212 1.542137 3 -0.226433 0.390355 0.437592 4 -0.204653 -2.388690 0.106218 In [17]: df[‘b’] = [[234]] * len(df) df Out[17]: a b c 0 -0.010414 … Read more