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. ...
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. ...
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 ...
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'] ...
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? ...
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...
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. ...
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 ...
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...
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...
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...
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...
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...
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: ...
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...
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...
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...
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...
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...
l1 = [4, 6, 8] l2 = [a, b, c] result = [(4,a),(6,b),(8,c)] How do I do that? ...
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...