list

How to randomize the entries in a List so the user sees a different DailyPrayer each time?

I have a method that does a lookup of some elements and returns them to the user: List<DailyPrayer> dailyPrayers = (List<DailyPrayer>) query.execute(); return dailyPrayers; These are daily prayers so I want the user to see a different prayer each time so they do not get bored with seeing the same content in the same order over and ove...

Move class attribute value to php variable

We have variable $menu with HTML inside (there is no loop, it comes from a function). On echo it gives the code like this: <ul id="menu"> <li id="some-id" class="many classes one"><a href="#">text</a></li> <li id="some-id" class="many classes second active"><a href="#">text</a></li> <li id="some-id" class="many classes thre...

Prolog GNU - Having a difficult time with this, lists and recursion

So , i still don't completely understand how lists and recursion work in prolog, could be why i am having trouble with this, but i don't even know how to begin this problem. There is a list of friends. f(a,b). f(a,c). f(a,d). f(b,c). f(b,e). f(b,f). f(c,e). f(c,g). f(g,e). etc.. I have to find if someone is a friend through someone e...

android listview refresh problem

im getting a weird problem when refreshing my listview it works fine until the device is rotated and then when refreshing it again it goes completely blank. can only be fixed by rotating the device again (as it is also refreshed in onCreate()) but then whenever its refreshed again it goes blank. problem persists until app is restarted. ...

Python - Most efficient way to compare # of words sequenced in "right" order across two strings/lists

Hi experts, I was wondering what the most computationally efficient Python way of cracking this problem would be. Say you have two strings (or lists from splitting those strings--doesn't matter), "this is the right string" vs. "this is right the string." We're assuming that the first string is always right, and a score will be assigne...

Removing duplicates members from a list of tuples

Hi, this question might have similars in SO but my case is a bit different. and I tried to adapt those answers to my problem but couldn't. so here is the thing: I have this list : [(['c', 'a', 'b'], 10), (['c', 'a', 'b'], 9),(['h','b'],2)] for example. I want to remove the duplicates in this list by keeping tuple that has the larger nu...

Creating Lists from files in Scheme

I've worked out how to read in the file and it works using the following code: (define p (read(open-input-file "starbucks4.sxml"))) But how do i store p as a list with elements separated by \n characters. Thanks. ...

Integer to Binary Erlang

Hi, I am trying to make an integer into a binary: 543 = <<"543">> How can I do this without integer_to_list(list_to_binary(K)). ...

List shared between different threads in .NET

I have a static List in a class that will be accessed by different threads, each one adding, reading and removing its own unique item from the list. I would like to know if I have to worry about making this variable thread safe, as even though the same List object is shared between threads, they only modify their own unique items ...

A question about lists in Python...

I'm having some trouble with a couple of hmwk questions and i can't find th answer- How would you write an expression that removes the first or last element of a list? i.e. One of my questions reads "Given a list named 'alist' , write an expression that removes the last element of 'alist'" ...

Uninstall methods in Android

Hey everybody, I was wondering where, or what is the methods used in the batch uninstaller programs? I know how to pull up lists of the applications, and the icons in a listview.. getting them into the right lists and whatever, but how do I actually uninstall the application? Thanksa ...

GNU Prolog - Build up a list in a loop

I need to build a new list with a "loop". Basically i can't use recursion explicitly, so i am using append to go through lists of list. I can get the element. Problem is i need to check this element and if something is true it returns another element i need to put back into the list. It does check correctly and it changes correctly. Pr...

challenge: optimize unlisting [easy]

Because SO is a bit slow lately, I'm posting an easy question. I would appreciate it if big fishes stayed on the bench for this one and give rookies a chance to respond. Sometimes we have objects that have a ridiculous amount of large list elements (vectors). How would you "unlist" this object into a single vector. Show proof that your ...

Python - Neaten this append/extend conditional

Hey, I have a method which I will accept either a single object or a list of objects. I want to add whatever is passed to another list. Currently, my method looks like this: def appendOrExtend(self, item): if type(item).__name__ == "list": self.list.extend(item) else: self.list.append(item) It seems to me that there shoul...

List/tree/Stack - Algorithm

Hey guys, I need to do a project at the college, it needs to use list/tree/stack to perform any task. I was thinking on the Google's algorithm to recognize the phrase while the guy is typing. Does anyone has this algorithm? Or any other better idea that use list/tree/stack? Thanks ...

Replace an element in a list in Scheme

Hi, I'm looking for a function in Scheme to replace a element in an equation by a value. Exemple : '(+ a b c a) with (1 2 3) should give me '(+ 1 2 3 1). (I don't want to resolve the equation, it was just an exemple) Basically, I want to say that a=1, b=2, c=3 To proceed, I extract the variables of my first list in another list. The...

splitting a dictionary in python into keys and values.

How can I take a dictionary and split it into two lists, one of keys, one of values. For example take: {'name': 'Han Solo', 'firstname': 'Han', 'lastname': 'Solo', 'age': 37, 'score': 100, 'yrclass': 10} and split it into: ['name', 'firstname', 'lastname', 'age', 'score', 'yrclass'] # and ['Han Solo', 'Han', 'Solo', 36, 100, 10] An...

how to pick up the last (or whatever) items of all vectors inside a list?

I have a dummy list here: > x <- c("a", "b", "c") > y <- c("d", "e", "f") > z <- list(x,y) > z [[1]] [1] "a" "b" "c" [[2]] [1] "d" "e" "f" If I want to assign another variable (e.g. w) to hold the last item (i.e. "c", "f") of all vectors (i.e. x, y) inside the list (i.e. z), how can I do that? Thanks! ...

Average the duplicated values from two paired lists in Python

Hello, in my code I obtain two different lists from different sources, but I know they are in the same order. The first list ("names") contains a list of keys strings, while the second ("result_values") is a series of floats. I need to make the pair unique, but I can't use a dictionary as only the last value inserted would be kept: inst...

How to get a list of week days in a month?

In this other question it shows how to get all days of a month. I need the same thing, but I only want to list days of week (I want to exclude weekends). How can I get a list of days of a month excluding weekends? ...