list

How do I split a string into a list Python?

Learning to program, trying to do this I have a string like this 2+24*48/32 and I want to split it into a list like this ['2', '+', '24', '*', '48', '/', '32'] I have messed around with .split() but that's messy as it returns a list, which means I would now have to iterate over two strings, etc ...

In Python, what is the fastest algorithm for removing duplicates from a list so that all elements are unique *while preserving order*?

For example: >>> x = [1, 1, 2, 'a', 'a', 3] >>> unique(x) [1, 2, 'a', 3] Assume list elements are hashable. Clarification: The result should keep the first duplicate in the list. For example, [1, 2, 3, 2, 3, 1] becomes [1, 2, 3]. ...

List the names of all the classes within a VS2008 project

Is there a quick & dirty way of obtaining a list of all the classes within a Visual Studio 2008 (c#) project? There are quite a lot of them and Im just lazy enough not to want to do it manually. ...

C++ strings without <string> and STL.

I've not used C++ very much in the past, and have recently been doing a lot of C#, and I'm really struggling to get back into the basics of C++ again. This is particularly tricky as work mandates that none of the most handy C++ constructs can be used, so all strings must be char *'s, and there is no provision for STL lists. What I'm cur...

Create many constrained, random permutation of a list

I need to make a random list of permutations. The elements can be anything but assume that they are the integers 0 through x-1. I want to make y lists, each containing z elements. The rules are that no list may contain the same element twice and that over all the lists, the number of times each elements is used is the same (or as clos...

How do I append to an alist in scheme?

Adding an element to the head of an alist (Associative list) is simple enough: > (cons '(ding . 53) '((foo . 42) (bar . 27))) ((ding . 53) (foo . 42) (bar . 27)) Appending to the tail of an alist is a bit trickier though. After some experimenting, I produced this: > (define (alist-append alist pair) `(,@alist ,pair)) > (alist-append ...

I need to join two lists, sort them and remove duplicates. Is there a better way to do this?

I have two unsorted lists and I need to produce another list which is sorted and where all the elements are unique. The elements can occur multiple times in both lists and they are originally unsorted. My function looks like this: (defun merge-lists (list-a list-b sort-fn) "Merges two lists of (x, y) coordinates sorting them and r...

.NET List<T> Concat vs AddRange

What is the difference between the AddRange and Concat functions on a generic List? Is one recommended over the other? ...

Is there a zip-like method in .Net?

In Python there is a really neat function called zip which can be used to iterate through two lists at the same time: list1 = [1, 2, 3] list2 = ["a", "b", "c"] for v1, v2 in zip(list1, list2): print v1 + " " + v2 The above code shoul produce the following: 1 a 2 b 3 c I wonder if there is a method like it available in .Net? I'm ...

The best of the non-obese technical books?

I have a bias towards the slim ones. (I am talking about technical books here ;-). By slim I mean the books I can read lying on the couch. That would approx to the books with no more than 400 pages I guess. GoF's design patterns has more pages, though I consider it as slim. I think you got the idea. Some of the best books I have read ar...

Sharepoint calculated field's formula for created by

i have a sharepoint list with 2 users for examole (user A and user B) i need a calculated field in the list items such that if user "A" created the item the field vaule will be "X" and if user "B" created the item fields value would be "Y" but i couldnt use [created by] in the furmiula of the calculated field !! why is that ?!! ...

Sorting matched arrays in Java

Let's say that I have two arrays (in Java), int[] numbers; and int[] colors; Each ith element of numbers corresponds to its ith element in colors. Ex, numbers = {4,2,1} colors = {0x11, 0x24, 0x01}; Means that number 4 is color 0x11, number 2 is 0x24, etc. I want to sort the numbers array, but then still have it so each element ma...

List all words in a dictionary that start with <user input>

How would a go about making a program where the user enters a string, and the program generates a list of words beginning with that string? Ex: User: "abd" Program:abdicate, abdomen, abduct... Thanks! Edit: I'm using python, but I assume that this is a fairly language-independent problem. ...

How can I join a list into a string (caveat)?

Along the lines of my previous question, how can i join a list of strings into a string such that values get quoted cleanly. Something like: ['a', 'one "two" three', 'foo, bar', """both"'"""] into: a, 'one "two" three', "foo, bar", "both\"'" I suspect that the csv module will come into play here, but i'm not sure how to get the out...

How to add Announcement list/webpart to Publishing Portal

I have a Publishing Portal site and I need to add some announcements to some of the pages. I've read an article which says that i have to create an announcement list to be able add an announcement web part but i can't seem to find any resources on how i can add an announcement list. Any help will be greatly appreciated. TIA! ...

Do I have to cause an ValueError in Python

I have this code: chars = #some list try: indx = chars.index(chars) except ValueError: #doSomething else: #doSomethingElse I want to be able to do this because I don't like knowfully causing Exceptions: chars = #some list indx = chars.index(chars) if indx == -1: #doSomething else: #doSomethingElse Is there a wa...

Which list<Object> implementation will be the fastest for one pass write, read, then destroy?

What is the fastest list implementation (in java) in a scenario where the list will be created one element at a time then at a later point be read one element at a time? The reads will be done with an iterator and then the list will then be destroyed. I know that the Big O notation for get is O(1) and add is O(1) for an ArrayList, while ...

Sharepoint: Deploy Custom Lists and New Columns in lists

I've created a custom list & also added a column in the Announcement List. Question is, how can I include those newly created items when I create a fresh Web Application (like a script, feature or something)? Additional Info: It's like when you're to deploy from your development machine to a staging or production server. I'd like to h...

What's the point of Perl's map?

Not really getting the point of the map function. Can anyone explain with examples its use? Are there any performance benefits to using this instead of a loop or is it just sugar? ...

splice() on std::list and iterator invalidation

The 3-argument form of list::splice() moves a single element from one list to the other. SGI's documentation explicitly states that all iterators, including the one pointing to the element being moved remain valid. Roguewave's documentation does not say anything about iterator invalidation properties of splice() methods, whereas the C+...