list

Python: Find identical items in multiple lists

I have a list of an arbitrary number of lists, for instance: [[1,2,3], [3,4,5], [5,6,7], [7,8,9]] Now I would like a list containing all elements that are present in more than one list: [3,5,7] How would I do that? Thanks! ...

sortable lists, with sortable lists...

hello there - i'm trying to have 3 levels of lists all of which are sortable & draggable into each other. Basically trying to set up an easy way to manage navigation menus with multiple levels. Its 90% there but for some reason it wont save an item into a child list. It just seems to get the parent id of the list it came from?! ie. a ...

How to separate one list in two via list comprehension or otherwise

If have a list of dictionary items like so: L = [{"a":1, "b":0}, {"a":3, "b":1}...] I would like to split these entries based upon the value of "b", either 0 or 1. A(b=0) = [{"a":1, "b":1}, ....] B(b=1) = [{"a":3, "b":2}, .....] I am comfortable with using simple list comprehensions, and i am currently looping through the list L t...

List<> Better to init with a maximum capacity and only use a fraction of that, or init with no capacity.

I have a List<MyStruct> that I'm initializing to be empty, and I will be populating this struct in a loop as I parse the data. I know that there is a maximum possible number of entries that will be inserted into this list. For now lets say 1000. However after my parsing of the 1000 entries I may end up only putting 2 into the List. So sh...

List<T>.AddRange implementation suboptimal

Profiling my C# application indicated that significant time is spent in List<T>.AddRange. Using Reflector to look at the code in this method indicated that it calls List<T>.InsertRange which is implemented as such: public void InsertRange(int index, IEnumerable<T> collection) { if (collection == null) { ThrowHelper.Throw...

Why is the + operator for List deprecated in Scala?

Why is the + operator for List deprecated in Scala? http://www.scala-lang.org/docu/files/api/scala/List.html#%2B%28B%29 ...

Property with Enumerable or list

I'm playing around with LINQ and related subjects and was wondering about the following. I've 2 methods of getting a Fibonacci sequence. I started with: public static IEnumerable<int> Fibonacci { get { int i = 0; int j = 1; int temp = 0; while (true) { ...

converting elements of a list to string

I would like to obtain the string text of the elements stored in a list, say List<Car>. Would the toArray() and the toString() methods be the best options? ...

How do you make a multiple-choice list from the sqlite database in Android?

I'm new to Android programming, and I wanted to pull list options from a column of the SQLite database for the user to select. How would I go about doing this? Like, say the database table to be read is called countries, and the columns were ID, country, and capital. How would I let the user pick from the list of capitals and have the ap...

How to create custom objects/list of custom objects in VB.NET?

I need two seperate lists, which every item is Integer, String, Bitmap - and one which every item is Integer, String String. However I don't know how to do this, or even where to look - I've googled for custom objects and custom object lists. What I'm trying to do is this. Custom Object1 is Integer, String, Bitmap Custom Object2 is Integ...

Bash output as Applescript list problems.

This is just driving me nuts. I am trying to read a file in bash, remove duplicates, sort, and then display a "list choice" window via applescript. My $DATALOG file is formatted like this: field1 field2 field1 field3 field1 field4 etc... Applescript=awk '{print $2}' $DATALOG | awk ' !x[$0]++' | sort -u | tr "_" " "| sed 's/^/\"/'...

Trying to create a system to merge two lists of "buzz words" together, forming every possibility for domain availability checking?

Hello, My problem originates from me trying to create names for all my crazy (brilliant?) ideas for business and products, which then need to have their purchasing availability checked for .com domain names. So I have a pen and paper system where I create two lists of words... List A and List B for example. I want to find or create a ...

Is there a typical name for a function like 'map' that operates on a list of argument lists instead of multiple lists of arguments?

(I finally posted and accepted an answer to the effect of "no, there isn't, and the question isn't actually that general".) Consider the Common Lisp function 'mapcar'. It takes a function and some lists as arguments, and calls the function with arguments pulled from the same position in each list. Do standard libraries typically have a...

WPF Datagrid binding to list problems

I have a list of custom objects: say Fruits with two string properties Name and Color. These are in a List. private readonly List<Fruit> fruitList = new List<Fruit>(); Then I load fruit objects into the list. I am trying to bind this list to WPF Datagrid: C#: dgFruit.ItemsSource = "{Binding}"; XAML: <toolkit:DataGrid Name="dgFru...

splitting a list of arbitrary size into only roughly N-equal parts

hi all, what is the best way to divide a list into roughly equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give a concrete case, if th...

put stockprices into groups when they are within 0.5% of each other

Hi: Thanks for the answers, I have not used StackOverflow before so I was suprised by the number of answers and the speed of them - its fantastic. I have not been through the answers properly yet, but thought I should add some information to the problem specification. See the image below. I can't post an image in this because i don't ...

Best way to handle list.index(might-not-exist) in python?

I have code which looks something like this: thing_index = thing_list.index(thing) otherfunction(thing_list, thing_index) ok so that's simplified but you get the idea. Now thing might not actually be in the list, in which case I want to pass -1 as thing_index. In other languages this is what you'd expect index() to return if it couldn...

Java - Tokenize Parameter List

I'm trying to create a method which takes a String parameter and then returns a two dimensional String array of parameter names and values. protected final String[][] setParams (String parms) { String[][] params; int i = 0; Pattern p = Pattern.compile(NEED_REGEX_HERE); Matcher m = p.matcher(parms); params = String[m...

python select specific elements from a list

Is there a "pythonic" way of getting only certain values from a list, similar to this perl code: my ($one,$four,$ten) = line.split(/,/)[1,4,10] ...

jQuery return position of list element with class on table column click

I was wondering how to return the position of a list element with a class of 'currentTab' in the following unordered list: <ul id="coverTabs"> <li class="currentTab"><a href="#">Individual</a></li> <li><a href="#">Couple</a></li> <li><a href="#">Family</a></li> <li><a href="#">Single parent family</a></li> </ul> The ...