list

Python Subclass Builtin List

Hi everyone, I want to subclass the list type and have slicing return an object of the descendant type, however it is returning a list. What is the minimum code way to do this? If there isn't a neat way to do it, I'll just include a list internally which is slightly more messy, but not unreasonable. Thank you! Edit: My code so far: c...

First Python list index greater than x?

What would be the most pythonesque way to find the first index in a list that is greater than x? For example, with list = [0.5, 0.3, 0.9, 0.8] The function f(list, 0.7) would return 2. ...

Lisp, a couple of questions about lists and recursion

Hey guys, sorry to overflow with so many questions. I have the following: (defun recursive-function (string) "returns list of strings" ;I am trying to return flat list ; create list L (append (mapcar 'recursive-function L))) But since recursive-function returns a list, I end up with a list of a list of a list..., whereas I want just ...

Multiple Sharepoint Forms

I am trying to split out what I originally wanted in a single form. The downside was that I wanted to keep multiple lists and I found that I could not use a single form with multiple lists. What I am trying to do is to keep my customer information in a separate list/form so I can re-use it in a different application as well. What I wo...

Overloading Java function with List<> parameter

I have 2 classes public class Customer{ ... public String getCustomerNumber(); ... } public class Applicant{ .... private Customer c; public Customer getCustomer(){ return c; } ... } When presented with a list of customers or applicants I want a function which iterates the list and does something with the CustomerNu...

Mathematica: Idiomatic way to replace values in a list that match a condition?

I want to truncate absolute values below an epsilon to 0, e.g., Truncate[{-3, -2, -1, 0, 1, 2, 3}, 1.5] -> {-3, -2, 0, 0, 0, 2, 3} I guess I could write a function using Scan[] and If[], but is there a more idiomatic "one-liner" way of doing it in Mathematica? ...

more pythonic way of finding element in list that maximizes a function

OK, I have this simple function that finds the element of the list that maximizes the value of another positive function. def get_max(f, s): # f is a function and s is an iterable best = None best_value = -1 for element in s: this_value = f(element) if this_value > best_value: best = element...

binding checkboxlist without the field name

i want to problem when i am binding checklistbox in that time i have not require the fields name at run time. ...

Venn Diagram up to 4 lists - outputting the intersections and unique sets

Hello, in my work I use a lot of Venn diagrams, and so far I've been relying on the web-based "Venny". This offers the nice option to export the various intersections (i.e., the elements belonging only to that specific intersection). Also, it does diagrams up to 4 lists. Problem is, doing this with large lists (4K+ elements) and more t...

IE6-7 table inside li leave a gap

Hi a am trying to create a tree using CSS. In FF works fine , IE6-7 fails. I have a ul/li structure and inside li i create a table to display the tree row. On IE i have a gap between li and table. Here is the code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional....

Unmarshalling a list using JAXB

Hi everyone. I know this is a beginner question, but I've been banging my head against a wall for two hours now trying to figure this out. I've got XML coming back from a REST service (Windows Azure Management API) that looks like the following: <HostedServices xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www....

Is it worthwhile to initialize the collection size of a List<T> if it's size reasonably known?

Is it worthwhile to initialize the collection size of a List<T> if it's reasonably known? Edit: Furthering this question, after reading the first answers this question really boils down to what is the default capacity and how is the growth operation performed, does it double the capacity etc.? ...

MySql: Operate on Many Rows Using Long List of Composite PKs

What's a good way to work with many rows in MySql, given that I have a long list of keys in a client application that is connecting with ODBC? Note: my experience is largely SQL Server, so I know a bit, just not MySQL specifically. The task is to delete some rows from 9 tables, but I might have upwards of 5,000 key pairs. I started ou...

Python: find a list within members of another list(in order)

If I have this: a='abcdefghij' b='de' Then this finds b in a: b in a => True Is there a way of doing an similar thing with lists? Like this: a=list('abcdefghij') b=list('de') b in a => False The 'False' result is understandable - because its rightly looking for an element 'de', rather than (what I happen to want it to do) 'd' ...

"Unix directories are lists of 'link' structures"

From http://en.wikipedia.org/wiki/Inode Unix directories are lists of "link" structures, each of which contains one filename and one inode number. I'd like to just get the length of this list of links, the names of the files in the directory aren't important at this point in my code. A solution in Perl would be preferred, but ...

In python, what is more efficient? Modifying lists or strings?

Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same? As an example, let's say I have two binary strings "11011" and "01001". If I represent these as lists, I'll be choosing a random "slice" point. Let's say I get 3. I'll Take the...

Sorting dictionary keys by values in a list?

I have a dictionary and a list. The values of the keys match those of the list, I'm just trying to find out how to sort the values in the dictionary by the values in the list. >>> l = [1, 2, 37, 32, 4, 3] >>> d = { 32: 'Megumi', 1: 'Ai', 2: 'Risa', 3: 'Eri', 4: 'Sayumi', 37: 'Mai' } I've tried using somethin...

Multi-Level Bullets Implementation

What is the best way of implementing multi-level lists/bullets in php? What I'm trying to implement is a system to take in short phrases, and categorize them within sections. However, at the same time, I would like to have each section to be collapsible and capable of having sub-sections within them. For Example: Section 10 Section 10...

Remove duplicates in list (Prolog)

I am completely new to Prolog and trying some exercises. One of them is: Write a predicate set(InList,OutList) which takes as input an arbitrary list, and returns a list in which each element of the input list appears only once. Here is my solution: member(X,[X|_]). member(X,[_|T]) :- member(X,T). set([],[]). set([H|T],[H...

List comprehension and functions

I'm a little confusing when try something like this b = [lambda x:x**i for i in range(11)] When I then try b[1](2) I have 1024 as a result that is wrong. But when I write so b = [(lambda i: lambda x:x**i)(i) for i in range(11)] all is OK >>> b[1](2) 2 >>> b[5](2) 32 It works fine but what's wrong in first code? ...