list

How to execute Vim commands in a file, like .vimrc?

I need to create a file with a list of commands (in particular key mappings) that I may sometimes need, like a .vimrc that I can execute inside Vim when I need them. ...

Format all elements of a list

I want to print a list of numbers, but I want to format each member of the list before it is printed. For example, theList=[1.343465432, 7.423334343, 6.967997797, 4.5522577] I want the following output printed given the above list as an input: [1.34, 7.42, 6.97, 4.55] For any one member of the list, I know I can format it by using, ...

Java Compare Two Lists

I have two lists ( not java lists, you can say two columns) For example **List 1** **Lists 2** milan hafil dingo iga iga dingo elpha binga hafil mike meat dingo milan elpha meat iga neet...

Finding maximum of a list of lists by sum of elements in Python

What's the idiomatic way to do maximumBy (higher order function taking a comparison function for the test), on a list of lists, where the comparison we want to make is the sum of the list, in Python? Here's a Haskell implementation and example output: > maximumBy (compare `on` sum) [[1,2,3],[4,5,6],[1,3,5]] > [4,5,6] And implementati...

How can I implement a list over an eventually consistent database?

I want to implement lists and queues over Cassandra, Riak, or any other eventually consistent store. Is this possible and how could I do it? I am looking for a general purpose algorithm. ...

JQuery jCarousel - Disabling external controls

I'm using JQuery and jcarousel, using external navigation controls: http://sorgalla.com/projects/jcarousel/examples/static_controls.html The problem here is the navigation buttons no longer disable as shown here: sorgalla.com/projects/jcarousel/examples/static_simple.html Is there a callback I can use to allow me to swap the active im...

How to create and display a list in Java?

i have to create a list of ,let's say 50 people, (in Java) and display the list, and i don't really know how to do that. so this is what i have tried to do so far . please correct and complete some of my code . public class Person { String name; String stuff; } public class CreatePerson { public static void ang() { ...

Python: create a function to modify a list by reference not value

Hey all- I'm doing some performance-critical Python work and want to create a function that removes a few elements from a list if they meet certain criteria. I'd rather not create any copies of the list because it's filled with a lot of really large objects. Functionality I want to implement: def listCleanup(listOfElements): i =...

In Python, are there builtin functions for elementwise boolean operators over boolean lists?

For example, if you have n lists of bools of the same length, then elementwise boolean AND should return another list of that length that has True in those positions where all the input lists have True, and False everywhere else. It's pretty easy to write, i just would prefer to use a builtin if one exists (for the sake of standardizati...

Getting the indices of all non-None items from a sub-list in Python?

As per the title, I have a nested lists like so (the nested list is a fixed length): # ID, Name, Value list1 = [[ 1, "foo", 10], [ 2, "bar", None], [ 3, "fizz", 57], [ 4, "buzz", None]] I'd like to return a list (the number of items equal to the length of a sub-list from list1), where the sub-...

How to Get A Joined Query to List Object

I have a dynamic sql query which contains more than one table joined. Normally I get this query to a datatable and use it. For now I want to get result of this query to a list object. Does anyone help me about this case? ...

List comprehension from multiple sources in Python?

Is it possible to replace the following with a list comprehension? res = [] for a, _, c in myList: for i in c: res.append((a, i)) For example: # Input myList = [("Foo", None, [1, 2, 3]), ("Bar", None, ["i", "j"])] # Output res = [("Foo", 1), ("Foo", 2), ("Foo", 3), ("Bar", "i"), ("Bar", "j")] ...

Making a python iterator go backwards?

Is there anyway to make a python list iterator to go backwards? Basically i have this class IterTest(object): def __init__(self, data): self.data = data self.__iter = None def all(self): self.__iter = iter(self.data) for each in self.__iter: mtd = getattr(self, type(each).__name__) ...

How do you solve this Haskell problem?

I want to define a function replicate to replicate a list of numbers by its value using only list comprehension, for example: replicate [5,1,3,2,8,1,2] output: [5,5,5,5,5,1,3,3,3,2,2,8,8,8,8,8,8,8,8,1,2,2] I know this would be easy to use the 'replicate' built in function but only list comprehension is allow, how can I do this? THAN...

Convert a sequence of sequences to a dictionary and vice-versa

One way to manually persist a dictionary to a database is to flatten it into a sequence of sequences and pass the sequence as an argument to cursor.executemany(). The opposite is also useful, i.e. reading rows from a database and turning them into dictionaries for later use. What's the best way to go from myseq to mydict and from mydic...

Order a List (C#) by many fields?

Hi everyone, I want to order a List of objects in C# by many fields, not just by one. For example, let's suppose I have a class called X with two Attributes, A and B, and I have the following objects, in that order: object1 => A = "a", B = "h" object2 => A = "a", B = "c" object3 => A = "b", B = "x" object4 => A = "b", B = "b" and I ...

Testing a (big) collection retrieved from a db

I'm currently doing integration testing on a database and I have the following sql statement: var date = DateTime.Parse("01-01-2010 20:30:00"); var result = datacontext.Repository<IObject>().Where(r => r.DateTime > date).First(); Assert.IsFalse(result.Finished); I need to test if the results retrieved from the statement, where the giv...

WPF List - ListItem Visibility

Greetings, I have a FlowDocument where List control is placed. Inside this list I have some ListItem. Is there any way to set some kind of Visibility for specific ListItem? I don't see a coressponding Property like Visibility for ListItem. When I set fontsize="0.1" then application hangs (it goes into infinite loop). ...

Probability algorithm: Finding probable correct item in a list (e.g John, John, Jon)

Hi, Take for example the list (L): John, John, John, John, Jon We are to presume one item is to be correct (e.g. John in this case), and give a probability it is correct. First (and good!) attempt: MostFrequentItem(L).Count / L.Count (e.g. 4/5 or 80% likelihood) But consider the cases: John, John, Jon, Jonny John, John, Jon, Jon I w...

Java: iterating through list of lists?

The question but in C#. So does Java have C#'s command? I need it for Matches-SearchTerm-Files-relationship. foreach(var i in BunchOfItems.SelectMany(k => k.Items)) {} [Why not for-loops?] I have done such structures in nested for loops but they soon become bloated. So I prefer something more succint like the above. public static Sta...