list

Erlang list comprehension with two lists in sequence?

Is it possible to use list comprehension on two lists, item by item, in sequence? Given A = [1,2,3], B = [4,5,6], get some C = [f(1, 4), f(2, 5), f(3, 6)]. In other words, a more direct/efficient way to do [f(U, V) || {U, V} = lists:zip(A, B)]. Similar question goes to binaries, if given A = <<1,2,3>> and B = <<4,5,6>>. This would be ve...

What's the standard algorithm for syncing two lists of objects?

I'm pretty sure this must be in some kind of text book (or more likely in all of them) but I seem to be using the wrong keywords to search for it... :( A common task I'm facing while programming is that I am dealing with lists of objects from different sources which I need to keep in sync somehow. Typically there's some sort of "master ...

XmlSerialization and List

I have the following class public class Notifications : List<Notification> { } Unfortunately, when it's serialized it looks like <ArrayOfNotification> <Notification> ... How can I get that root node to be Notifications? I've tried a few different attributes on the class, but none compile. ...

string split function in delphi

Hello, All actually i was opened question previously, but can't get answer what i exactly want, so i would like to ask again thanks All for example, i have some text file name is 'test.txt' , and inside text contents looks like hello all good day happy is and i want to modify following source to iterate from first index of 'hello ...

Python - assign lists within nest to variable

Hi folks, I am new to python and would appreciate a little help. How does one do the following: Having converted each line within a file to a nested list, e.g. [['line 1', 'a'], ['line 2','b']] how do I flatten the list so that each line is associated with a variable. Assume that the first member in each list, i.e. i[:][0], is known...

Java: Iterating HashMap - Algorithm needed

Hi! I have a question. I have a list of names, say 8 names: Joe, Bob, Andrew, Bill, Charlie, Sarah, Ann, Victor The count of names might differ**. 1) What should I use as name list? Hashmap, Vector, Hashtable, List, ArrayList? 2) I need to match them up like this: Joe-Bob, Andrew-Bill, Charlie-Sarah, Ann-Victor. Could you please sho...

A pythonic way how to find if a value is between two values in a list

Having a sorted list and some random value, I would like to find in which range the value is. List goes like this: [0, 5, 10, 15, 20] And value is, say 8. The standard way would be to either go from start until we hit value that is bigger than ours (like in the example below), or to perform binary search. grid = [0, 5, 10, 15, 20] va...

Python: incorporating index from for loop as part of a list name

How does one generate a set of lists that incorporate the index from a for loop in the list name: for j in range(10): li"j" = [] How can the index 'j' be part of the name, so the lists are li0, li1, li2, ... Thanks! ...

In what case would I use a tuple as a dictionary key?

I was studying the difference between lists and tuples (in Python). An obvious one is that tuples are immutable (the values cannot be changed after initial assignment), while lists are mutable. A sentence in the article got me: Only immutable elements can be used as dictionary keys, and hence only tuples and not lists can be us...

Android - drag and drop - list rearrange

How can I create a list where I can rearrange list items with dragging list rows to another row and so on (to change to order)? Just like on the HTC Hero in the clocks app where you can rearrange the order of clocks? Wouter ...

How to check if a list is ordered?

I am doing some unit tests and I want to know if there's any way to test if a list is ordered by a property of the objects it contains. Right now I am doing it this way but I don't like it, I want a better way. Can somebody help me please? // (fill the list) List<StudyFeedItem> studyFeeds = Feeds.GetStudyFeeds(2120, DateTime.Today.Ad...

Json.net deseralize to a list of objects in c# .net 2.0

Hi, I'm trying to deseralize some json into a collection (list), but I'm not sure which method will return a list of objects, or do I have to loop through something and copy it to my own list? Can anyone tell me the syntax or method I should use for this. I've created my object with some properties, so it's ready to be used to hold th...

Prolog: Test if an arbitrary list is symmetric

Is there a way to test wether an arbitrary list is symmetric? For example: ?- symmetric([a,b,b,a]). true. ?- symmetric([a,b,c,a]). false. ?- symmetric([a,a]). true. My attemp was to compare the first element to the last element and if they are equal to remove them and proceed with the rest of the list; otherwise fail. Succeed if th...

Lists in Haskell : data type or abstract data type?

Hi, From what I understand, the list type in Haskell is implemented internally using a linked list. However, the user of the language does not get to see the details of the implementation, nor does he have the ability to modify the "links" that make up the linked list to allow it to point to a different memory address. This, I suppose, ...

convert code to use Linq

Hi all, I have the following code, I want to use Linq, any possible ?? I have one list of users, and I need generate other list. any help ? thanks in advanced, greetings SortedList<ClaveUsuarioPersonal, UsuarioRe> users = new SortedList<ClaveUsuarioPersonal, UsuarioRe>(); if (this.UsuarioRe.UsuarioSar != null) ...

Pointing to the first object in a linked list, inside or outside class?

Which of these is a more correct way to store the first object in a linked list? Or could someone please point out the advantages/disadvantages of each. Thanks. class Node { int var; Node *next; static Node *first; Node() { if (first == NULL) { first = this; next = NULL; ...

C# List<T>.ConvertAll in .NET 2.0

I have a list of strings. All of the strings have whitespace that needs to be converted to underscores. I am fully capable of using a for or foreach loop to do this. I am still relatively new to C# and would like to become more familiar with it. With that said, my question is: How can I get the following code to work in .NET 2.0? When I...

C# Given a desired order need a space efficient list reordering or sorting

My objective is: Given a list of entries, and a desired ordering, rearrange the list of entries according to this ordering. The list will be very large, so space efficiency is important. Ex: List<Entry> data = ReadDataFromSomeWhere(); // data => [a, b, c]; List<int> ordering = RandomPermutation(data.Count); // ordering => [2, 1, 3]; da...

Python: Split list into list of dicts?

Just beginning with python and know enough to know I know nothing. I would like to find alternative ways of splitting a list into a list of dicts. Example list: data = ['ID:0:0:0', 'Status:Ok', 'Name:PhysicalDisk0:0:0', 'State:Online', 'FailurePredicted:No', 'ID:0:0:1', 'Status:Ok', ...

GroupBy CAMl query is giving Render Failed error

Hello, I have custom list definition.I want to display rows as GroupBy with some column names. I added a query in Schema.xml like below. <Query> <GroupBy> <FieldRef Name="Title" visible="false" /> <FieldRef Name="Followed By" /> </GroupBy> </Query> If i use two filter group its working fine.No iss...