list

How do I remove something form a list, plus string matching?

[(',', 52), ('news', 15), ('.', 11), ('bbc', 8), ('and', 8), ('the', 8), (':', 6), ('music', 5), ('-', 5), ('blog', 4), ('world', 4), ('asia', 4), ('international', 4), ('on', 4), ('itunes', 4), ('online', 4), ('digital', 3)] Suppose I have this list, with tuples inside. How do I go through the list and remove elemen...

how to add the values stored in a session variable in php?

Okay I have two pages-- page1.php and page2.php .Both of these pages have select lists.I have posted the values selected by the user to script.php which has them stored in session variables. I need to add the values (which are the ones selected by the user from the select lists in both the pages) and display this total value in page3....

Make Dictionary From 2 List

trying to make dictionary with 2 list one being the key and one being the value but I'm having a problem. This is what I have so far: d={} for num in range(10): for nbr in range(len(key)): d[num]=key[nbr] say my key is a list from 1 to 9 and value list is [2,4,0,9,6,6,8,6,4,5] how do i assign so it that its like {0:2, 1:4, et...

Returning a property of type List<>

Hello there, I'm currently trying to return a match to a Foreach statement which is contained in a list. I have a class that has a List of string, i'm using this as a collection of tracks. I'm trying to perform a check to see if the given track i pass in through is a match to any tracks stored in the object (CD.cs) and if so return the...

Returning a match from a List<KeyValuePair<string,string>>

Hello, I currently have a class that uses the KeyValuePair with List to store a collection of tracks in the format of Key = track, Value = artist. I'm trying to provide a way of searching for a particular track and if there are any matches then return the entire matching CD. This is my attempt so far: public CompilationCD FindTrackIn...

how to copy a list to a new list, or retrieve list by value in c#

I noticed in c# there is a method for Lists: CopyTo -> that copies to arrays, is there a nicer way to copy to a new list? problem is, I want to retrieve the list by value to be able to remove items before displaying them, i dont want the original list to be modified, that too doesnt seem to be easily attainable, any ideas? ...

Java: Sort an unmodifiable list

How would one do this? I have tried creating a new, empty list, then copying unmodifiable list's elements to it, but I'm getting unsupported operation error. Any help is appreciated. ...

How to add an item to a list of generics declared as a list of an abstract object in C#

Hello everybody. So I have an abstract class named "Account" : public abstract class Account { private string _FinancialInstitution; public string FinancialInstitution { get { return _FinancialInstitution; } ... } } And I have two other classes that extends from those two: public class CreditCard : A...

python : list index out of range error

I have written a simple python program l=[1,2,3,0,0,1] for i in range(0,len(l)): if l[i]==0: l.pop(i) This gives me error 'list index out of range' on line if l[i]==0: After debugging I could figure out that i is getting incremented and list is getting reduced. However, I have loop termination condition i < len(l)....

Convert a Python list with strings all to lowercase or uppercase

I have a python list variable that contains strings. Is there a python function that can convert all the strings in one pass to lowercase and vice versa, uppercase? Regards ...

A generic type as a parameter.

My first question is, is it possible to specify a generic type as a parameter, secondly, is anything such as the pseudo code ive listed below possible? I assume it will be using .net 4.0 and the dynamics modifier but i am more interested in a pre 4.0 solution. public static void SomeMethod(List<T> l, Type type, Control samplecontro...

c# - How to deserialize a generic list<T> when I don't know the type of (T)?

Hi, for auditory reasons I stores the arguments of the business methods serialized into the database using the binaryformatter. The problem is that when an argument is a generic list I don't find the way to cast the deserialized object because I don't know the type, or If I will know the type I don't know how to cast the object at runt...

Suppose I have 2 vectors. What algorithms can I use to compare them?

Company 1 has this vector: ['books','video','photography','food','toothpaste','burgers'] ... ... Company 2 has this vector: ['video','processor','photography','LCD','power supply', 'books'] ... ... Suppose this is a frequency distribution (I could make it a tuple but too much to type). As you can see...these vectors have things tha...

Initialize a list of objects in Python

Hi all, I'm a looking to initialize an array/list of objects that are not empty -- the class constructor generates data. In C++ and Java I would do something like this: Object lst = new Object[100]; I've dug around, but is there a Pythonic way to get this done? This doesn't work like I thought it would(I have 100 references to the s...

JQuery/Javascript Clear/Reset Drop down List to original values.

Ok dokey, got a bit of jquery up and running, lovely stuff. $(document).ready(function() { $inputs = $("#tbxProdAC, #ddlBuyer, #txtbxHowMany, radTopx"); $.each($inputs, function() { $(this).focus(function() { $.each($inputs, function() { $(this).val(''); $(this).at...

jQuery, remove item from middle of list, then refresh list?

I have a ul list that is loaded by an included PHP file. Those items have a "Delete" link that removes them from the list and the database. When an item is removed from the center of the list using this code: $list.find('#city_' + $id).remove(); It leaves a space in the list like this: What can I do to refresh that list, without g...

Featured articles list

I'd like to display 10 articles from "featured" category. Only the first should have title and excerpt, the rest 9 only titles. How'd I do that? Many thanks for your help. ...

How do I sort the result of an SQL join by a single column in PHP

I have a database with a list of locations e.g.: C_ID | Name 1 | Italy 2 | Germany 3 | France 4 | Spain and in a seperate table, a list of people who are from those countries, P_ID | Name | C_ID 1 | John | 1 2 | Mark | 1 3 | Paul | 2 4 | Pierre | 3 5 | Alan | 2 I have grabbed ...

PHP Array to List

How do I go from this multidimensional array: Array ( [Camden Town] => Array ( [0] => La Dominican [1] => A Lounge ) [Coastal] => Array ( [0] => Royal Hotel ) [Como] => Array ( [0] => Casa Producto [1] => Casa Wow ) [Florence] => Array ( [0] => Florenciana Hotel ) ) to this <ul> Camden Tow...

C# - List<> concurrent removing and adding

Hello, I am not too sure, so i thought i'd ask. Would removing and adding items to a System.Collections.Generic.List<> object be non-thread safe? My situation: When a connection is received, it is added to the list, but also at the same time, there's a worker that's removing dead connections and such. Is there a problem? Will a lock ...