empty-list

How do you pass a List<> of Lists<> to a background worker?

北城余情 提交于 2021-02-08 11:42:16
问题 I have a backgroundWorker that is processing two lists. I need to pass the Lists to the worker. the result is empty lists. Code to pass the Lists (and 2 other parameters). In my test, each list has 20+ items, and the List<> items show that the 20+ items are intact just prior to the call. In the inspector they say "Count" followed by the number of items. List<Object> arguments = new List<object>(); // Add arguments to pass to background worker arguments.Add(managerSource); arguments.Add

SwiftUI list empty state view/modifier

不打扰是莪最后的温柔 提交于 2021-01-20 08:41:42
问题 I was wondering how to provide an empty state view in a list when the data source of the list is empty. Below is an example, where I have to wrap it in an if/else statement. Is there a better alternative for this, or is there a way to create a modifier on a List that'll make this possible i.e. List.emptyView(Text("No data available...")) . import SwiftUI struct EmptyListExample: View { var objects: [Int] var body: some View { VStack { if objects.isEmpty { Text("Oops, loos like there's no data

SwiftUI list empty state view/modifier

£可爱£侵袭症+ 提交于 2021-01-20 08:41:12
问题 I was wondering how to provide an empty state view in a list when the data source of the list is empty. Below is an example, where I have to wrap it in an if/else statement. Is there a better alternative for this, or is there a way to create a modifier on a List that'll make this possible i.e. List.emptyView(Text("No data available...")) . import SwiftUI struct EmptyListExample: View { var objects: [Int] var body: some View { VStack { if objects.isEmpty { Text("Oops, loos like there's no data

Ambiguous type variable in a test for empty list

旧时模样 提交于 2021-01-20 07:09:14
问题 Consider the following snippet which defines a function foo which takes in a list and performs some operation on the list (like sorting). I tried to load the snippet in ghci : -- a function which consumes lists and produces lists foo :: Ord a => [a] -> [a] foo [] = [] foo (x:xs) = xs test1 = foo [1, 2, 3] == [2, 3] test2 = null $ foo [] yet the following error occurs: No instance for (Ord a0) arising from a use of ‘foo’ The type variable ‘a0’ is ambiguous Note: there are several potential

Ambiguous type variable in a test for empty list

落花浮王杯 提交于 2021-01-20 07:07:12
问题 Consider the following snippet which defines a function foo which takes in a list and performs some operation on the list (like sorting). I tried to load the snippet in ghci : -- a function which consumes lists and produces lists foo :: Ord a => [a] -> [a] foo [] = [] foo (x:xs) = xs test1 = foo [1, 2, 3] == [2, 3] test2 = null $ foo [] yet the following error occurs: No instance for (Ord a0) arising from a use of ‘foo’ The type variable ‘a0’ is ambiguous Note: there are several potential

Collections.emptyList() instead of null check?

本小妞迷上赌 提交于 2020-01-11 21:55:12
问题 If I have a rarely used collection in some class which may be instantiated many times, I may sometimes resort to the following "idiom" in order to save unnecessary object creations: List<Object> list = null; void add(Object object) { if (list == null) list = new ArrayList<Object>(); list.add(object); } // somewhere else if (list != null) for (Object object : list) ; Now I was wondering if I couldn't eliminate those null checks using Collections.emptyList() , however then I would have to alter

Is there a tensorflow equivalent to np.empty?

こ雲淡風輕ζ 提交于 2019-12-20 01:58:09
问题 Numpy has this helper function, np.empty, which will: Return a new array of given shape and type, without initializing entries. I find it pretty useful when I want to create a tensor using tf.concat since: The number of dimensions of the input tensors must match, and all dimensions except axis must be equal. So it comes in handy to start with an empty tensor of an expected shape. Is there any way to achieve this in tensorflow? [edit] A simplified example of why I want this netInput = np.empty

Selecting rows of pandas DataFrame where column is not empty list

感情迁移 提交于 2019-12-19 19:14:02
问题 I have a pandas DataFrame where one column contains lists and would like to select the rows where the lists are not empty. Example data: df = pd.DataFrame({'letter': ["a", "b", "c", "d", "e"], 'my_list':[[0,1,2],[1,2],[],[],[0,1]]}) df letter my_list 0 a [0, 1, 2] 1 b [1, 2] 2 c [] 3 d [] 4 e [0, 1] What I'd like: df letter my_list 0 a [0, 1, 2] 1 b [1, 2] 4 e [0, 1] What I'm trying: df[df.my_list.map(lambda x: if len(x) !=0)] ... which returns an invalid syntax error. Any suggestions? 回答1: