list

Determine if a Python list is 95% the same?

This question asks how to determine if every element in a list is the same. How would I go about determining if 95% of the elements in a list are the same in a reasonably efficient way? For example: >>> ninety_five_same([1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]) True >>> ninety_five_same([1,1,1,1,1,1,2,1]) # only 80% the same Fals...

Silverlight 4 Binding to List of List of objects

Hello, someone can suggest how I can do it? I have a public static int _index in App.xaml.cs I have a List < List < Person > > foreach List < Person > I create a new button -> foreach button, the click.event of it opens a PopUp. Now I want to bind the Textboxes of the PopUp to the person-propertys For example: P...

"Iterable<Element> cannot be cast to List<Element>" - Isn't `List` a type of `Iterable`?

I called a getElements method which returns Iterable<Element>. I did this: List<Element> elements = (List<Element>) getElements(); This generates the error: java.lang.ClassCastException: com.utesy.Element$3 cannot be cast to java.util.List I thought a List was a type of Iterable? ...

C++ Floating point exception with global list array

I'm just getting started, but I'm already having trouble. So far, my code is simply: (In Searcher.h) #ifndef SEARCHER_H #define SEARCHER_H #include <string> #include <list> using namespace std; class Searcher{ public: Searcher( int& x ); ~Searcher(); private: int size; list<string> * lists; }; #endif (In Searcher.cpp) ...

How would a write a LINQ query to compare with a list of values ?

I have basically to select all employee from companies which are being passed so a variable - CompanyListIds - Contains list of all company ids.. var result=DataContext.Employee(e=>e.CompanyId==companyId).ToList(); The above is a query I have for selecting from one company, now how would I modify it to compare with all the companyi...

Grails: How do I create filter like the ones in MS Excel??

I want to sort the elements in my list and have the option of filter them the same way MS Excel does. So it should be able to keep the filtered elements in the table and apply a filter within those results as well. Also be able to sort them without refreshing the whole table. Any help is greatly appreciated! FG ...

java: reverse list

I want to have a reversed list view on a list (in a similar way than List#sublist provides a sublist view on a list). Is there some function which provides this functionality? I don't want to make any sort of copy of the list nor modify the list. It would be enough if I could get at least a reverse iterator on a list in this case thoug...

Showing a List View when a button is clicked: Android

Hey Guys, I am trying to implement a drop down list when a button is clicked. So, I have a text view and a button in a navigation bar(nav.xml) and a corresponding list view. This navigation bar is included in another page( products.xml) when the button is clicked i get the list view right below the button(which is what i want to ac...

Python: determine length of sequence of equal items in list

I have a list as follows: l = [0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,2,2,2] I want to determine the length of a sequence of equal items, i.e for the given list I want the output to be: [(0, 6), (1, 6), (0, 4), (2, 3)] (or a similar format). I thought about using a defaultdict but it counts the occurrences of each item and accumulates i...

Prolog, find minimum in a list.

Hi, in short: How to find min value in a list? (thanks for the advise kaarel) long story: I have created a weighted graph in amzi prolog and given 2 nodes, I am able to retrieve a list of paths. However, I need to find the minimum value in this path but am unable to traverse the list to do this. May I please seek your advise on how t...

about python list step issue when the element is long type

In [2]: list=range(627) In [3]: list[::150] Out[3]: [0, 150, 300, 450, 600] the above code is right,but if i use the bellow code,caution:the l means long type, the return result is not like above,what's the hell? In [4]: list=[1323l,123123l,4444l,12312312l] In [5]: list=[1323l,123123l,4444l,12312312l] In [6]: list[::2] Out[6]: [13...

how to use python list comprehensions replace the function invoke inside of "for" stmt?

Sorry, I just found the id = [conn.cursor() for x in range(100) ] also works, so my concern will not be a problem anymore. Thanks for all of your answer, all of you are really fast. ===================== All, id = [(conn.cursor(),x) for x in range(100) ] >>> id [(<sqlite3.Cursor object at 0x01D14DA0>, 0), (<sqlite3.Cursor object ...

Enumerating all pairs constructible from two lazy lists in OCaml

Hi everyone, I am attempting to enumerate the set of all pairs made of elements from two lazy lists (first element from the first list, second element from the second list) in OCaml using the usual diagonalization idea. The idea is, in strict evaluation terms, something like enum [0;1;2;...] [0;1;2;...] = [(0,0);(0,1);(1;0);(0;2);(1;1)...

Convert dictionary to list collection in C#

I have problem when trying to convert dictionary to list. Example if I have dictionary with template string as key and string as value. Then i wish to convert dictionary key to list collection as string. Dictionary<string, string> dicNumber = new Dictionary<string, string>(); List<string> listNumber = new List<string>(); dicNumber.Add...

prevent print() from outputting list indices in R

I have a list containing 6 plots, made like this: voi=c('inadist','smldist','lardist') plist<-llply(voi, function(v,df,s) { list( assign(paste(v,'.violin'), bwplot(groupname~df[,which(colnames(df)==v)]|fCycle*fPhase, data=df, groups=groupname, col=rainbow(1), box.ratio=3, main=paste('Dis...

C++ how to check if folder is empty / list existing files

Possible Duplicate: How do you iterate through every file/directory recursively in standard C++ Hello everyone! I've been looking for a way to check if a determined folder is empty or not, and if it isn't, list the existing files in the folder, but of course to no avail. I've been looking around and found something called di...

How can I store the actual control in a list?

Long story short, I would like to take my usercontrols that are loaded dynamically and stick them into a list that references the actual object that has been loaded. So I can go into the list and pull results from the usercontrol. I would like to use mycontrol.GetResult() and it will then reference the control and grab the results from t...

How to prevent a ModelBinder error in a mandatory fields of a list?

I've got this object created from EntityFramework from my database. [EdmEntityTypeAttribute(NamespaceName="ContactCoreModel", Name="TargetLang")] [Serializable()] [DataContractAttribute(IsReference=true)] public partial class TargetLang : EntityObject { #region Factory Method /// <summary> /// Create a new TargetLang object...

jquery show/hide divs and a counter

I have a random amount of DIVs (minimum 1, max of 10) <div id="container"> <div class="foo">Content</div> <!-- div 1 --> <div class="foo">Content</div> <!-- div 2 --> <div class="foo">Content</div> <!-- div 3 --> <div class="foo">Content</div> <!-- div 4 --> <div class="foo">Content</div> <!-- div 5 --> <div class="foo">Content</div> <!...

Python - List Mapping

Hey, I have several lists that I would like to map together, but I can't quite work my head around how to do it. I am scraping a live feed of Horse Racing results. The feed only lists the course/time once and three horses and their positions (top three) OR four horses and blank (i.e. "") positions IF the race was abandoned. These are t...