list

A Transpose/Unzip Function in Python

I have a list of 2-item tuples and I'd like to convert them to 2 lists where the first contains the first item in each tuple and the second list holds the second item. For example: original = [('a', 1), ('b', 2), ('c', 3), ('d', 4)] # and I want to become... result = (['a', 'b', 'c', 'd'], [1, 2, 3, 4]) Is there a builtin function th...

"bad words" filter

Not very technical, but... I have to implement a bad words filter in a new site we are developing. So I need a "good" bad words list to feed my db with... any hint / direction? Looking around with google I found this one, and it's a start, but nothing more. Yes, I know that this kind of filters are easily escaped... but the client will ...

.Net 2.0 - How efficient are Generic Lists?

I'm creating an app that holds loads of loads of user data in memory, and it's mostly keeping it all in List<T> structures (and some Dictionary<T,T> when I need lookup). And I'm wondering... How efficient are Lists? How much memory overhead do I get for each of them? (that is, memory space in addition to what the objects they contain w...

How would you make a comma-separated string from a list?

What would be your preferred way to concatenate strings from a sequence such that between each two consecutive pair a comma is added. That is, how do you map, for instance, [ 'a', 'b', 'c' ] to 'a,b,c'? (The cases [ s ] and [] should be mapped to s and '', respectively.) I usually end up using something like ''.join(map(lambda x: x+',',...

inline lists with graphical links in css

given this html: <ul id="topnav"> <li id="topnav_galleries"><a href="#">Galleries</a></li> <li id="topnav_information"><a href="#">Information</a></li> </ul> and this css: #topnav_galleries a, #topnav_information a { background-repeat: no-repeat; text-indent: -9000px; padding: 0; margin: 0 0; overflow: hidden; height: 4...

Can I Do This In Lisp?

I have been searching everywhere for this functionality in lisp, and have gotten nowhere. find the index of something in a list. example: (index-of item InThisList) replace something at a specific spot in a list. example: (replace item InThisList AtThisIndex) ;i think this can be done with 'setf'? return an item at a specific index. ...

Customize the Sharepoint add list column page

I have defined a custom Sharepoint list for special attributes related to a software application inventory and installed it as a feature. I also want to group these attributes in categories. How could I change the Sharepoint page that allows the user to add a column to a list, so that when the user adds a column to my custom list type (c...

Lisp list iteration

I have a function that gets x(a value) and xs(a list) and removes all values that are bigger than x from the list. Well it doesn't work, can you tell me why? (defun biggerElems(x xs) (let ((xst)) (dolist (elem xs) (if (> x elem) (setf xst (remove elem xs)))) xst)) ...

Populating a list of integers in .NET

I need a list of integers from 1 to x where x is set by the user. I could build it with a for loop eg assuming x is an integer set previously: List<int> iList = new List<int>(); for (int i = 1; i <= x; i++) { iList.Add(i); } This seems dumb, surely there's a more elegant way to do this, something like the PHP range method ...

How to check if element in groovy array/hash/collection/list?

How do I figure out if an array contains an element? I thought there might be something like [1,2,3].includes(1) which would evaluate as 'true' ...

Console.WriteLine and generic List

I frequently find myself writing code like this: List<int> list = new List<int> { 1, 3, 5 }; foreach (int i in list) { Console.Write("{0}\t", i.ToString()); } Console.WriteLine(); Better would be something like this: List<int> list = new List<int> { 1, 3, 5 }; Console.WriteLine("{0}\t", list); I suspect there's some clever way ...

Python: What is the best way to check if a list is empty?

For example, if passed the following: a = [] How do I check to see if a is empty? ...

Returning an element from a List in Scala

Hello, I've recently been working on a beginner's project in Scala, and have a beginner question about Scala's Lists. Say I have a list of tuples ( List[Tuple2[String, String]], for example). Is there a convenience method to return the first occurence of a specified tuple from the List, or is it necessary to iterate through the list by...

Efficiently selecting a set of random elements from a linked list

Say I have a linked list of numbers of length N. N is very large and I don’t know in advance the exact value of N. How can I most efficiently write a function that will return k completely random numbers from the list? ...

How to get a list of current open windows/process with Java?

Does any one know how do I get the current open windows or process of a local machine using Java? What I'm trying to do is: list the current open task, windows or process open, like in Windows Taskmanager, but using a multi-platform approach - using only Java if it's possible. Thanks! ...

In Python, how can you easily retrieve sorted items from a dictionary?

Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key? For example, you had this: d = {...

SharePoint Content Query Web Part

Hi, I have a content query web part that queries by content type against a site collection. I have grouped it by content type so I have: -- Agenda (Content Type) ----Agenda #1 ----Agenda #2 -- Report (Content Type) ----Report #1 ----Report #2 I would like to show a second grouping for site, so: -- Agenda (Content Type) ----This Site...

In Python how do I sort a list of dictionaries by values of the dictionary?

I got a list of dictionaries and want that to be sorted by a value of that dictionary. This [{'name':'Homer', 'age':39}, {'name':'Bart', 'age':10}] sorted by name, should become [{'name':'Bart', 'age':10}, {'name':'Homer', 'age':39}] ...

Sharepoint: Best way to display lists of non-Sharepoint content with "compatible" UI?

I've built a web part for Sharepoint that retrieves data from an external service. I'd like to display the items in a way that's UI-compatible with Sharepoint (fits in with its surroundings.) I'm aware of the "DataFormWebPart" but was unable to get one working properly. It requires a valid DataSource and I was unable to build one from...

Sharepoint Item Level Access & performance

i have created a workflow activity that do give the item creater of a specific list full control on the item and set everyone else to read only access (permission) someone told me that doing it this way (if i have a lot of users) the performance will go down dramatically is that correct ?!! if yes what is the best solution to create...