list

scala return on first Some in list

I have a list l:List[T1] and currently im doing the following: myfun : T1 -> Option[T2] val x: Option[T2] = l.map{ myfun(l) }.flatten.find(_=>true) The myfun function returns None or Some, flatten throws away all the None's and find returns the first element of the list if any. This seems a bit hacky to me. Im thinking that there mig...

Linked List in C (memory problems)

I'm creating a simple linked list in C in order to get used to some memory management. I've defined a node structure that holds a char* key, char* value and a node* next. void newnode(node *n, int x, int y) { n->key = malloc(x*sizeof(char)); n->value = malloc(y*sizeof(char)); } //This how i create a new node given a key and v...

Valgrind / Memory Errors

I'm receiving the following errors repeatedly throughout my code when I use valgrind. I'm not quite sure what these mean and I can't identify the uninitialized values. ==16795== Conditional jump or move depends on uninitialised value(s) ==16795== at 0x4A06E8A: strcmp (mc_replace_strmem.c:412) ==16795== by 0x4009C7: dictionary_add...

Problems with C++ containers

I have a std::list in a C++ program, which contains objects of a Class A. Lets say I have 10 objects in it. I have a reference to the 6th object stored, in another data structure say ref_6. Lets say I need to remove the 8th element from my list. To do this, I would use pop_front 8 times and store 8 objects in a vector and use push_front...

Valgrind Uninitialized Values (making a linked list data struct)

I've created a linked list class, but this function is producing valgrind errors based saying that there is a conditional jump based upon an uninitialized value in this function. I'm not exactly sure what I need to do to fix it. Essentially there is a node class for the linked list and this is iterating over all the nodes checking if t...

Compare items in a List to each other, by a seperate function.

Hello, I have a function that checks whether a string represents a filesystemlocation beneath another string. My question however should be applicable to any function returning boolean. Here is the function anyway... private bool IsItemBelowPath(string item, string path) { if (path == Path.GetPathRoot(path)) { path = ...

C# Derived Type to Generic List as Parameter

Hello :) I am trying to do the following in C# 4.0: I have a Base Class and 2 derived classes public class Base {} public class DerivedClass1 : Base {} public class DerivedClass2 : Base {} I want to do something like this, but it doesn't work. How to I tell a Generic List to accept a Base Class and the derived classes of the bas...

Converting flat data from sql to List<Item>

First of all I'm sorry if you feel this question has been raised before, but I can't seem to wrap my mind around this one, although it's rly not the hardest thing to do.. Basically I have a query result from sql which holds several rows, existing out of : id, parentid, name, description, level level is the depth of the item viewed as...

Find elements in a list that's not in the second list (in scala)

Suppose I have two lists: val a = List('a', 'b', 'c') val b = List('a', 'b', 'c', 'd') I want to get the element which is not in the first list (in this case it's 'd'). I know I can do this with a loop, but is there any fancy functional way to do this quickly in one line? I've been looking at the Scala List API, but could only found ...

I've got two list but one itemclick method

the problem is that i have two listView but one itemClick method, if i put a switch, the position on one list is the same than the other list... And by example if i want to open a popup on an item in one list, the item in the same position in the other list gonna do the same thing, and i really don't want, can you help me? Thanks there ...

Comparing lists in Haskell, or more specifically what is lexicographical order?

Hi, I'm just beginning this nice hashkell beginners tutorial: http://learnyouahaskell.com on this page on lists he explains that lists are compared in compared in lexicographical order, he gives this example: ghci> [3,2,1] > [2,10,100] True From some googling it seems to me that lexicographical ordering means in alphabetical or seq...

How to list all the processes which are using/accessing a given Linux kernel driver

Hi, Is there any way to list all the processes which are using/accessing a given Linux kernel driver? I've got a (framebuffer) driver which I'm trying to rmmod, however the system is returning Module is in use, and I'd like to get to the bottom of it and see what process is still using it. Can we get first the file descriptors that're...

Android listView null pointer exception

Hello everyone, I need a small help in List view. I am generating a list View, but whenever i do getChildAt(int position) it throws null pointer exception. Here is the code _list=(ListView)findViewById(android.R.id.list); _loadListElements(); _showListUI(); _list.getChildAt(1).setBackgroundColor(Color.WHITE); ...

Concatenating two lists - difference between '+=' and extend()

I've seen there are actually two (maybe more) ways to concatenate lists in Python: One way is to use the extend() method: a = [1, 2] b = [2, 3] b.extend(a) the other to use the plus(+) operator: b += a Now I wonder: Which of those two options is the 'pythonic' way to do list concatenation and is there a difference between the two (...

Python - Way to distinguish between item index in a list and item's contents in a FOR loop?

For instance, if I wanted to cycle through a list and perform some operation on all but the final list entry, I could do this: z = [1,2,3,4,2] for item in z: if item != z[-1]: print z.index(item) But instead of getting the output "...0 1 2 3," I'd get "...0 2 3." Is there a way to perform an operation on all but t...

Diacritics alphabetical ordering in C#

Hello! I want to know how do you perform a reliable alphabetical ordering (for a listbox) of people's full names with the diacritics of the language in C sharp? Thanks in advance. Q: So you just want to treat diacritics as the "original" letter? (eg: João is the same as Joao)? – NullUserException A: I want to treat them as they should...

C++: Copying hashmap contents to pointer list

I have a hashmap which contains items of struct Foo (not pointers). Now, I want to have pointers of those items in a list. How can I do this? I have tried to iterate the hashmap and insert the &*iter's to the list but the pointers get invalidated as soon as they are out of scope. I should be able to do this without dynamic allocation,...

skip the latest wordpress posts in wp_get_archives()

Hi! In my sidebar, I show a list of the latest wordpress posts like this: wp_get_archives('type=postbypost&limit=10'); This will also show links to the posts that are currently visible on the front page of my blog. It makes no sense to include those posts in the list if they are visible on the home page. In the codex, I could not find...

Listing ol li up to down in 2 column with CSS

Hi friends, I have ol li listing (in 1 ol tag), I need to list it as below. must be a way to do it in CSS. Appreciate helps! thanks a lot! ...

Datastructure Interview Questions and answers

Hi, please post the possible data structure interview Questions and answers.. it will be helpfull for all who reffers this post. Thanks ...