list

Ordered ListSet

ListSet (collection.immutable.ListSet) is a inverse ordered set. I need ordered set. This is a example of original ListSet: var a = ListSet(1,2,3) var ite = a.iterator ite.next // returns 3 ite.next // returns 2 ite.next // returns 1 And this is a example of I need: var a = ListSet(1,2,3) var ite = a.iterator ite.next // returns 1 it...

How to convert c# generic list to json using json.net?

I am converting my datatable to c# generic list. DataTable dt = mydata(); List<DataRow> list = dt.AsEnumerable().ToList(); Now how can i convert this list to json using json.net? Any suggestion. Sample of json format should be like this, {"Table" : [{"userid" : "1","name" : "xavyTechnologies","designation" : "", "phone" : "9999999...

Grails AddTo in for loop

I am facing a problem due to that i'm newbie to grails i'm doing a website for reading stories and my goal now is to do save the content of the story into several pages to get a list and then paginate it easily .. so i did the following. in the domain i created two domains one called story and have this : class Story { String title ...

Help With Printing a single item from list inside list in python

I first create my grid: grid = [] for x in range(1,collength + 1): for y in range(1,collength + 1): grid.append([x,y,'e']) Then I make que for my grid and I want to manipulate the que based on the 0, 1, and 2 position of the lists inside the lists: floodfillque = [] grid = floodfillque for each in floodfillque: floo...

Python list to store class instance??

Given a python class class Student(): and a list names = []; then I want to create several instances of Student() and add them into the list names, names = [] # For storing the student instances class Student(): def __init__(self, score, gender): self.score = score self.gender = gender And now I want to check out ...

Can I create a "view" on a Python list?

I have a large list l. I want to create a view from element 4 to 6. I can do it with sequence slice. >>> l=range(10) >>> lv=l[3:6] >>> lv [3, 4, 5] However lv is copy of a slice of l. If I change the underlying list, lv does not reflect the change. >>> l[4] = -1 >>> lv [3, 4, 5] Vice versa I want modification on lv reflect in l as ...

C# List<T>.BinarySearch return value when value not found

I am confused about the BinarySearch method of List in case when the item does not exist. I've got List<long> theList = {1, 3, 5, ...}. theList.BInarySearch(0) returns 0, and theList.BInarySearch(3) returns 1, as expected. However, theList.BinarySearch(1) returns -2, and not -1 as I'd expect. The MSDN manual says: "Return value: T...

Overriding append method after inheriting from a Python List

Hi, I want to create a list that can only accept certain types. As such, I'm trying to inherit from a list in Python, and overriding the append() method like so: class TypedList(list): def __init__(self, type): self.type = type def append(item) if not isinstance(item, type): raise TypeError, 'item i...

flex 4.1 s:List: how can i force the list to load all the items, not only the visible items ?

Hello. I'm creating a facebook application in flex. I'm actually working on the friends component that shows your friends who are using the application. now, each friend has a profile image. I created the component using a s:List element. In the Skin Class of the element i configured the requestedColumnCount to 3, which means it shows...

CSS: How do I make a horizontal (UL) list keeping each item at a uniform width?

That is, without defining a specific 'width' amount for each individual item. As in, the widest element (by its content) sets the width for each of the other elements. Additionally, how do I span said list 100% across its container, also keeping each item the same width? ...

list index out of range error received

hey guys, beginner here. I have written a program that outputs files to .txt's and am using another to read them and use them. i have used a list to store these values (len(..) gives me 100 for all files). However, whenever i run this: for w in range(1,20): # i want files file01-file20 excluding file00 for x in range(100): c...

points as function parameters C

this is probably a simple solution I am not that familiar with C just trying to port my java data structure assignments to C. this is the error i am getting: test.c:4: error: expected ‘)’ before ‘*’ token test.c:11: error: expected ‘)’ before ‘*’ token #include <stdio.h> #include <stdlib.h> void to_screen(NODE *cur){ while(cur->...

Creating a dynamically sized Flex list component

I know there are a lot of questions about dynamic sizes for Flex components, but this one is quite specific and the other answers aren't a whole lot of help. Briefly, I need a List that resizes to exactly fit its content, unless that height exceeds its (dynamically sized) parent container. My requirements are as follows: The component ...

Erlang - Split a list into lists based on value

I am trying to split this list List = [[<<"5">>, <<"54">>], [<<"00">>], [<<"35">>, <<"54">>, <<"45">>, <<"55">>], [<<"00">>],[ <<"5">>]] into List = [[<<"5">>, <<"54">>], [<<"35">>, <<"54">>, <<"45">>, <<"55">>], [<<"5">>]] Basically based on the <<"00">> What is the best BIF to go about this, I have some code, but its sloppy, an...

data.frame rows to a list

I have a data.frame which I would like to convert to a list by rows, meaning each row would correspond to its own list elements. In other words, I would like a list that is as long as the data.frame has rows. So far, I've tackled this problem in the following manner, but I was wondering if there's a better way to approach this. xy.df <...

Calculate the sum of matrices in a list or a 3D array

Given a list (length = n) of 2x2 matrices, how do I calculate the sum of all those matrices (and get a 2x2 matrix) ? How can I do it, if instead of a list I have those matrices in a (2 x 2 x n) dimensional array ? ...

double dealloc problem while cleaning up a C++ STL list of pointers

Hi all, Problem: I try to deallocate memory pointed by pointer items of an STL list. This should work fine but in my case, there can be duplicate pointers in the list and I get a double dealloc exception even though I test whether the pointer is NULL or not (see source code below). How can I solve this problem ? Environment: Debian...

How to sort a List in C#?

I have the following List : List<Dictionary<int, Dictionary<string, string>>> lngList lngList.Add(new Dictionary<int,Dictionary<string,string>>().Add(1,new Dictionary<string,string>().Add("Item1Key","Item1Value"))); lngList.Add(new Dictionary<int,Dictionary<string,string>>().Add(3,new Dictionary<string,string>().Add("Item1Key","Item1Val...

Python List Help

I have a list of lists that looks like: floodfillque = [[1,1,e],[1,2,w], [1,3,e], [2,1,e], [2,2,e], [2,3,w]] for each in floodfillque: if each[2] == 'w': floodfillque.remove(each) else: tempfloodfill.append(floodfillque[each[0+1][1]]) That is a simplified, but I think relevant part of the code. Does the flood...

Make select list output in alphabetical order in Rails?

Hi Everyone, I have a select list in my model which lists a persons name with their employers name: <li>Case Handler Name<span><%= f.select :person_id, Person.all.collect { |x| [x.name_and_company, x.id] } %></span></li> def name_and_company return "#{personname} (#{company})" end Is it possible to force the select list to output ...