list

How to check if head is list in F#

Is there a function to check if an object is a list? I did it like this: try let x = unbox<list<obj>>(l) .... with | _ -> ... But i would like to check it with an if or match instead if it is possible. ...

Deleting record in sharepoint list

Hi I want to delete records in list view in sharepoint. This should only be a logical delete the actual data itself should not be deleted . How to accomplish thsi ? Please suggest ...

Convert and merge strings into a list in Python

In Python I have four strings that include the formatting of a list: line1 ="['a.b.c','b.c.a','c.d.e']" line2 ="['def','efg']" line3 ="['f']" line4 ="['g']" How do I merge them all so I get a valid Python list such as: SumLine = ['a.b.c','b.c.a','c.d.e','def','efg','f','g'] ...

Scheme built-in to check list containment

In Python I can do "x in list" to see if the list contains x. Is there any equivalent built-in in Scheme to do this? ...

Is there a common name for a function that takes a list of lists and returns a single list containing the contents of those lists?

EDIT: My question was originally "Is there a standard name for a function that flattens a list of lists, but only one level deep?", but Chuck's answer is phrased much closer to what I actually wanted to ask, so I renamed it. All three answers were useful to me, though. Thanks. 'flatten' seems to be a well-accepted name for a function th...

In memcached, you can put a List as a value. Can you put a list in beanstalkd?

Actually, I would like to use this for logging. I want to put a dictionary into beanstalkd. Everytime someone goes into my website, I want to put a dictionary into beanstalkd, and then every night, I want a script that will get all the jobs and stick them in the database. THis will make it fast and easy. ...

Why not expose List(Of String) in the parameters of web service in VB.NET?

The FxCop says in a rule that generic List should not be exposed to the outside world. But I do not understand why and what is the replacement for the generice List? Reference : http://msdn.microsoft.com/en-in/library/ms182142%28en-us%29.aspx ...

Why ICollection index does not work when instantiated?

When we declare a parameter as ICollection and instantiated the object as List, why we can't retrive the indexes? i.e. ICollection<ProductDTO> Products = new List<ProductDTO>(); Products.Add(new ProductDTO(1,"Pen")); Products.Add(new ProductDTO(2,"Notebook")); Then, this will not work: ProductDTO product = (ProductDTO)Products[0]; W...

Search Python list and return 2 or more of the same character

Hey, I've just started to learn Python and I'm creating the game Hangman. I've got the basic functionality down. I have a list containing the words and they're randomly selected. I have an input for the user to guess letters and check it against the list that the word is split into, I have another list that the correctly guessed letters...

Python: How do I dynamically alter methods of dict and list objects?

Here is a mockup of what I want to do: alist = [1,2,3,4,5] # create a vanilla python list object replacef (alist) # replace __setitem__, extend,... with custom functions alist[0]=2 # now the custom __setitem__ is called This is for a DSL project where the syntax should be as close to normal python as possible, so sub...

Explain Python .join()

I'm pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings. I try: strid = repr(595) print array.array('c', random.sample(string.ascii_letters, 20 - len(strid))) .tostring().join(strid) and get something like: 5wlfgALGbXOahekxSs9wlfgALGbXOahekxSs5 Why does...

C# - Creating a List from an existing Dictionary

Hello, I have a Dictionary<> collection that contains characters. The collection has items added and removed constantly by multiple threads. Would initializing a new List<> collection using the dictionary need a lock? Example code: List<Character> charsToUpdate = new List<Character>(this.manager.characters.Values); Thanks in advance...

functions that produce lists of lists in scheme

Hi, I'm trying to use scheme to write a function f that takes a number n and a function g and returns a list of lists of length n, but according with booleans according to the pattern indicated by g. For example, the function f should take n say 3 and the function g which makes every 3rd item on the list a true. It should return this: ...

A List processing problem in F#

I am trying to do problem 12 in Project Euler. numDivisor64 is to calculate number of divisors. I wrote this F# code: let problem12 = {1L..300000L} |> Seq.map (fun x->x*(x+1L)/2L) |> Seq.map numDivisor64 |> Seq.filter (fun x->x>500L) The problem asks to find the number rather than its # of divisors. Besides writing this in a l...

pythonic way to explode a list of tuples

I need to do the opposite of this http://stackoverflow.com/questions/756550/multiple-tuple-to-two-pair-tuple-in-python Namely, I have a list of tuples [(1,2), (3,4), (5,6)] and need to produce this [1,2,3,4,5,6] I would personally do this >>> tot = [] >>> for i in [(1,2), (3,4), (5,6)]: ... tot.extend(list(i)) but I'd like...

How to expose STL list over DLL boundary?

I have a DLL which needs to access data stored in STL containers in the host application. Because C++ has no standard ABI, and I want to support different compilers, the interface between the application and DLL basically has to remain plain-old-data. For vectors this is relatively straightforward. You can simply return the memory blo...

How can I create a java list using the member variables of an existing list, without using a for loop?

I have a java list List<myclass> myList = myClass.selectFromDB("where clause"); //myClass.selectFromDB returns a list of objects from DB But I want a different list, specifically. List<Integer> goodList = new ArrayList<Integer>(); for(int i = 0;i++; i<= myList.size()) { goodList[i] = myList[i].getGoodInteger(); } Yes, I could...

RandomAccessSubList not serialized

I am trying to get a sublist of a List but I want the sublist to be serialized. I found out that when we get sublist from an ArrayList the sublist is not serialized. To overcome this, this is what I am doing: ArrayList serializedSublist = new ArrayList(); //getQuestions() returns RandomAccessSubList getQuestions().addAll(serializedSu...

How to join lists element-wise in Python?

l1 = [4, 6, 8] l2 = [a, b, c] result = [(4,a),(6,b),(8,c)] How do I do that? ...

list comprehension in F#

I am trying to do some list comprehension in F#. And I found this. let evens n = { for x in 1 .. n when x % 2 = 0 -> x } print_any (evens 10) let squarePoints n = { for x in 1 .. n for y in 1 .. n -> x,y } print_any (squarePoints 3) The first still works ok, but the second is outdated. The latest (1.9.7.8) F# compiler...