Finding first and last index of some value in a list in Python
Is there any built-in methods that are part of lists that would give me the first and last index of some value, like: verts.IndexOf(12.345) verts.LastIndexOf(12.345) ...
Is there any built-in methods that are part of lists that would give me the first and last index of some value, like: verts.IndexOf(12.345) verts.LastIndexOf(12.345) ...
So for a list that has 1000 elements, I want to loop from 400 to 500. How do you do it? I don't see a way by using the for each and for range techniques. ...
Anyone knows how to access the index itself so for a list like this: ints = [8,23,45,12,78] when I loop through it using a for loop, how do I make access the for loop index, from 1 to 5 in this case? ...
Given a list of objects, I am needing to transform it into a dataset where each item in the list is represented by a row and each property is a column in the row. This DataSet will then be passed to an Aspose.Cells function in order to create an Excel document as a report. Say I have the following: public class Record { public int I...
I am thinking of doing this way: List sList = new ArrayList(); // Add elements. if (sList != null) { String listString = sList.toString; listString = listString.subString(1, listString.length() - 1); } I somehow found this to be neater than using the StringBuilder/StringBuffer approach. Any tho...
Right now I have vector3 values represented as lists. is there a way to subtract 2 of these like vector3 values, like [2,2,2] - [1,1,1] = [1,1,1] Should I use tuples? If none of them defines these operands on these types, can I define it instead? If not, should I create a new vector3 class? ...
I saw this code in Erlang: [X-$0 || X<-someFun()] In that line I found the -$0 syntax very useful. I read the code and estimated what it means, but I'm not quite sure: is it split all numbers? I'd like to see the explanation or man page of that syntax but I can't find it. Can anyone show me the right page? ...
When programming in Python, is it possible to reserve memory for a list that will be populated with a known number of items, so that the list will not be reallocated several times while building it? I've looked through the docs for a Python list type, and have not found anything that seems to do this. However, this type of list buildin...
Hi I am querying the Sharepoint Lists using the Sharepoint Library in .net. I noticed that there is more than one title field. How can I get the user defined title field? SPListItem item = myItemCollection[i]; item["Title"] <- provides me the wrong title field Is this a known issue, any work around? Thanks However if I go into m...
I have a point class like: class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; and a list of points: std::list <Point> pointList; std::list <Point>::iterator iter; I'm pushing points on to my pointList (although the list might contain no Points yet if none have been pushed ye...
So you can export a list to a spread sheet, but can you do the opposite? Preferably from an Excel sheet. ...
I've a List of this type List> that contains this List<int> A = new List<int> {1, 2, 3, 4, 5}; List<int> B = new List<int> {0, 1}; List<int> C = new List<int> {6}; List<int> X = new List<int> {....,....}; I want to have all combinations like this 1-0-6 1-1-6 2-0-6 2-1-6 3-0-6 and so on. According to you is This possibile to resolv...
I have a list of items as a part of a web application. The question is how user could manipulate the order of items in the list (not the list sort order). The typical way is to use arrow buttons to move items up or down. The other way is the drag-and-drop. But are there any other ways for a user interface for list reordering? ...
Hi there, I am trying to write a view that will generate a report which displays all Items within my Inventory system, and provide summaries at a certain point. This report is purely just an HTML template by the way. In my case, each Item is part of an Order. An Order can have several items, and I want to be able to display SUM based s...
I've a problem! I've a List <List<Class>> L = new List<List<Class>>(); where Class contains IDLinea Posizione And so on... I want to have a Distinct List<List<Class>> Where there are no objects with same lines. For example: List <List<Class>> L = new List<List<Class>>(); var A = new List<Class>(); Class C = new Class(); C.ID...
Most of my programming experience is in a language where there is one collection data structure -- an array. Now that I'm working primarily in .NET, I've come to appreciate the vast number of tools available to me, but I also find it difficult to determine which tools is best suited for each problem. I find this to be the case often wi...
Why does python 2.5.2 have the following behavior >>>[2].extend([]) == [2] False >>> [2].extend([]) == None True $ python --version Python 2.5.2 I assume I'm not understanding something here, but intuitively I'd think that [2].extend([]) should yield [2] ...
On a design I am coding, there is a horizontal list that serves as the navigation for the site. It spans the entire width of the page. You can see it here: http://aquate.us/film/ Now, the <ul> contained within div#navigation refuses to act centered within the div. It seems to be offset towards the left side. I've searched the net and n...
The following script stores all the files and directories in the array @file_list. How do I only filter only files with the .lt6 extension and none other than that? opendir (CURRDIR, $localdir); @file_list = grep !/^\.\.?$/, readdir CURRDIR; print STDOUT "Found Files: @file_list\n"; cheers ...
I have a list of type System.IO.FileInfo, and I would like to randomize the list. I thought I remember seeing something like list.randomize() a little while back but I cannot find where I may have seen that. My first foray into this yielded me with this function: Private Shared Sub GetRandom(ByVal oMax As Integer, ByRef currentVals As...