I can see the advantage of using two stacks if an array implementation is used since stacks are more easily implemented using arrays than stacks are.
But if linked-lists are used, what is the advantage?
The act of popping the stack onto the queue increases overhead for both linked-list and array implementations.
...
I'm still learning some of this c# stuff, and I couldn't find an answer to this question. Assuming that I have a list of MyObject implementing MyInterface
public class MyObject : IMyInterface { ...}
public List<MyObject> MyObjectList;
How can I return an IEnumerable<IMyInterface> with the contents of MyObjectList?
I mean, right now...
I am trying to take one string, and append it to every string contained in a list, and then have a new list with the completed strings. Example:
list = ['foo', 'fob', 'faz', 'funk']
string = 'bar'
*magic*
list2 = ['foobar', 'fobbar', 'fazbar', 'funkbar']
I tried for loops, and an attempt at list comprehension, but it was garbage. As...
I am going brain dead on this; I have several List' defined, based on specific classes (c1, c2, c3...). I have a method that will process information on these lists. What I want to do is pass in the specific list, but have the method accept the generic list, and then via typeof determine what specific work to do. I know its possible,...
I have a Sharepoint site with a List which has a complex View on it. When I save the site as a template and made a site from it the List contents are preserved and the View is available for selection but it is not selected by default. I have checked the "make this View default" checkbox when adding the View and if I manually go in and se...
I'm going through a whole bunch of tuples with a many-to-many correlation, and I want to make a dictionary where each b of (a,b) has a list of all the a's that correspond to a b. It seems awkward to test for a list at key b in the dictionary, then look for an a, then append a if it's not already there, every single time through the tupl...
In my C# project I have a static List that gets filled immediately when declared.
private static List<String> inputs = new List<String>()
{ "Foo", "Bar", "Foo2", "Bar2"};
How would I do this in Java using the ArrayList?
I need to be able to access the values without creating a instance of the class.
Is it possible?
...
I was resolving some prolog exercises when I fond myself with some difficulties resolving the following one:
Consider you have this fact base about object:
object(obj1).
object(obj2).
object(obj3).
object(obj4).
object(obj5).
material(obj1,wood).
material(obj2,wood).
material(obj3, glass).
material(obj4, glass).
material(obj5, ...
I have a list of file locations stored as strings. I want to be able to open a separate window for all of the different strings. What would be the best way to do that? Essentially, You click a button, the strings are constructed and they are left in a list. When I was prototyping, I built a small program to display the contents of one st...
Hey guys,
So, I have a navigation that is a list and has sublists and sublists.
Basically, the nav is by default collapsed, but if people click on a page that's in a sublist, I want to show the parent list. And if it's a sublist of a sublist, I need both parent lists to show. I have it set up, but, I don't like putting 5 .parent().pare...
thelist = [{'color':'green', 'time':4}, {'color':'red','time':2},{'color':'blue','time':5}]
How do I say:
If "red" is in thelist and time does not equal 2 for that element (that's we just got from the list):
...
I would like to take bites out of a list (or array) of a certain size, return the average for that bite, and then move on to the next bite and do that all over again. Is there some way to do this without writing a for loop?
In [1]: import numpy as np
In [2]: x = range(10)
In [3]: np.average(x[:4])
Out[3]: 1.5
In [4]: np.average(x[4:8])
...
I am getting this exception:
Collection was modified; enumeration operation may not execute.
when executing this section of code:
List<T> results = new List<T>();
foreach (T item in items)
if (item.displayText.ToLower().Contains(searchText.ToLower()))
results.Add(item);
return results;
I can't see why I get this exce...
Hello. I have an array with subjects and every subject has connected time. I want to compare every subjects in the list. If there are two of the same subjects, I want to add the times of both subjects, and also want to delete the second subject information (subject-name and time). But If I delete the item, the list become shorter, and I ...
I want to sort the array c. But I don't get the answer a,b,c,d. Instead I get a,b,d,c. What could I do, for sorting the whole array and not only one row?
EDIT: I want to sort the numbers. And the connected letters, should have the same order like the sorted numbers. sorry my question wasn't clear. Maybe I should join number and letters ...
Let's say i have a multidimensional list l:
l = [['a', 1],['b', 2],['c', 3],['a', 4]]
and I want to return another list consisting only of the rows that has 'a' in their first list element:
m = [['a', 1],['a', 4]]
What's a good and efficient way of doing this?
...
I'm building a very simplistic unordered list tree in XHTML with multiple levels deep. The way it works is that you click a parent node, and it uses the jQuery .load() API to make an AJAX call back to the server to see if this node has children. If it does, it inserts those nodes inside. When you click the parent link again, it does a .r...
I want to create a usercontrol that takes lists of different objects. These objects would be assigned to the control at design time. Now I want to be able to use linq to object to sort this list inside the usercontrol. Can anyone give me any ideas as how to go about it?
...
Django doesn't support getting foreign key values from list_display or list_filter (e.g foo__bar). I know you can create a module method as a workaround for list_display, but how would I go about to do the same for list_filter? Thanks.
...
So, just for fun, I've been playing with a CountedList type in Haskell, using Peano numbers
and smart constructors.
Type-safe head and tail just seem really cool to me.
And I think I've reached the limit of what I know how to do
{-# LANGUAGE EmptyDataDecls #-}
module CountedList (
Zero, Succ, CountedList,
toList, ofList,
empty,...