list

Iterate over a list, returning the current, next and the element before current

Hello StackOverflow, I have problems with writing an specific application in a scala-esque and elegant way. I tried this for some time now, but I cannot find a "good" solution to this Problem: Given that I have the following List: List("foo", "bar", "baz", "blah") I want to Iterate over this list, not only giving me the current elem...

python: processing a 16-element list into an 8-element list

I have a list of 16 elements [a00,a01,a02,...,a15] and would like to compute a list [b0,b1,b2,b3,b4,b5,b6,b7] where b0 = a00*256+a01 b1 = a02*256+a03 b2 = a04*256+a05 (etc.) what's the easiest way of doing this? (I'm a beginner in python) ...

Python, Stdin and List: accepting only positive numbers?

Do not code like this. Please, read the hints by the accepted answer. I tried to remove the junk but I coundn't. Code import sys a = [] i=0 for line in sys.stdin: try: n = float(line) a.append(n) i+=1 except ValueError: print 'Number please!'; ...

How to make a HTML list appear without the bullets signs using CSS only?

The browser will consider the list existence and arrange them accordingly, however won't show the small icon next to each one of them like the following: Normal list appear like the following: text A text B text C I want them to appear like this text A text B text C ...

How to cast an object to a list of generic type in F#

In the following snippet my intention is to convert a System.Object (which could be an FSharpList) to a list of whatever generic type it is holding. match o with | :? list<_> -> addChildList(o :?> list<_>) | _ -> addChild(o) Unfortunately only list<obj> is ever matched as a list. I would ...

WebKit doesn't paint background-color for entire width of final inline list item

On our website http://www.dimagi.com, the items in the jQuery menu near the top of the screen gain a background-color on hover. The hover background-color of the rightmost list item ("About Us") is cut off at the very right edge of the text, seemingly only in WebKit (tested Safari and Chrome in Windows XP). Can anybody see what I might...

getting list without k'th element efficiently and non-destructively

I have a list in python and I'd like to iterate through it, and selectively construct a list that contains all the elements except the current k'th element. one way I can do it is this: l = [('a', 1), ('b', 2), ('c', 3)] for num, elt in enumerate(l): # construct list without current element l_without_num = copy.deepcopy(l) l_witho...

List with multiple indexes

Given a generic List I would need some kind of index (in the database sense) that would allow me fast retrieval. The keys for this index would not be unique, so I can't use a dictionary. Here's what I have in mind: Given a class Foo { P1, P2, P3 } that may have data like this { "aaa", 111, "yes" } { "aaa", 112, "no" } { "bbb", 111, "no"...

Changing an array to list in TFS Reports

Creating a report in Team Foundation Server(TFS) and my parameter is set as an array and I want to be able to display this array. I want to be able to switch the array to a list and then be able to show what is selected out of the list by the parameter the user selects. Can someone help please?? :) ...

Can Python's list comprehensions (ideally) do the equivalent of 'count(*)...group by...' in SQL?

I think list comprehensions may give me this, but I'm not sure: any elegant solutions in Python (2.6) in general for selecting unique objects in a list and providing a count? (I've defined an __eq__ to define uniqueness on my object definition). So in RDBMS-land, something like this: CREATE TABLE x(n NUMBER(1)); INSERT INTO x VALUES(1...

java: resetting ListIterator?

I need to traverse a LinkedList a number of times, in a way that suggests using ListIterator. Is there a way to reset a ListIterator? or is it better to just create a new one? (and what if I can't because I don't have access to the list?) edit: and is there a way to create a ListIterator that points to the end of the list? (so that has...

Efficient way to shift a list in python

What is the most efficient way to shift a list in python? Right now I have something like this: >>> shift = lambda l, n: l[n:]+l[:n] >>> l = [1,2,3] >>> shift(l,1) [2, 3, 1] >>> shift(l,2) [3, 1, 2] >>> shift(l,0) [1, 2, 3] Is there a better way? ...

java extend or wrap a class to add extra functionality

When you want to add some extra information into a class, what way would you prefer: would you extend that class or make a wrapper around it? In my particular scenario, I want to add some pagination information with a List that I get from database. That pagination information will include: int currentPage; int totalResults; int contain...

How do I pass values from one SharePoint page to another?

Here's my specific predicament: I have a custom List Display Form that I am editing in SharePoint designer. It has the standard field editing form, and a Web part zone with a custom list Web part in it. When a user comes to this page, they're arriving here from clicking on an existing item in a list, we'll call it the "Site List." Each ...

Pythonic Way to Create Union of All Values Contained in Multiple Lists

Hi all, Doing some XML processing in python. (Edit: I'm forced to use Python 2.4 for this project, boo!) I want to know what is the most Pythonic way to do this (create union of all values in multiple lists): def getUniqueAttributeValues(xml_attribute_nodes): # split attribute values by whitespace into lists result_lists=lis...

What is the best friend list table design?

What is the best friend-list table design (for performance)? Probably there should not be many rows for every frienship. What Facebook and Myspace is doing? (in MySQL) ...

Implementation check list Framework

Suppose iam moving one SP ( or an alter script etc..) from Developement enviornment to QA enviornment . Before migration , i want to check a list of things like , all the tables used in the sp are present , all the functions or sub sp's are present , or in the case of alter script , if any index is present in the column iam trying to cha...

Identify groups of continuous numbers in a list

I'd like to identify groups of continuous numbers in a list, so that: myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20]) returns: [(2,5), (12,17), 20] And was wondering what the best way to do this was (particularly if there's something inbuilt into Python). Edit: Note I originally forgot to mention that individual numbers should be...

Python linked list O(1) insert/remove

Hey, I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there is a mature lib...

How would I create a Program that would take a list of names, and sort them into EVEN groups?

Hello all, I want to be able to create a program that will take a list of names from a .txt file (Doesnt have to be a txt, maybe excell, whatever is easiest) and generate those names into groups or "teams". I have 30 "users" that have to be sorted into "Teams". I want to be able to do this fairly, so I want to random :P. I haven't ye...