Suppose I have class animal and classes cat and dog extending it. I want to do something along the lines of:
foreach (class a in {cat, dog})
if (a.isValid(parameters))
doStuff();
isValid is a static method from animal that just checks if the given parameters define an object of the given type
doStuff means I'm doing stuf...
Suppose I have a given Object (a string "a", a number - let's say 0, or a list ['x','y'] )
I'd like to create list containing many copies of this object, but without using a for loop:
L = ["a", "a", ... , "a", "a"]
or
L = [0, 0, ... , 0, 0]
or
L = [['x','y'],['x','y'], ... ,['x','y'],['x','y']]
I'm especially interested in the th...
I have two ordered lists and user can move items between them. I am using jQuery UI's Selectable for both of them. Problem is that when I move item from the middle of the list it leaves an empty space behind. How can I make list shrink according to the how many items is actually in the list?
HTML
<ol id="allUnits">
<li class="ui-st...
Hi,
Can anyone tell me if a linkedlist of structures will be allowed to grow larger than the equivalent List (given that a list uses a doubling strategy for increasing the size of it's internal array).
So given a struct that is say 40 bytes (I know about the 16 bytes and structure thing, but I am working with some legacy code here and ...
I have a list of elements, and each element consists of four seperate values that are seperated by tabs:
['A\tB\tC\tD', 'Q\tW\tE\tR', etc.]
What I want is to create a larger list without the tabs, so that each value is a seperate element:
['A', 'B', 'C', 'D', 'Q', 'W', 'E', 'R', etc.]
How can I do that in Python? I need it for my cou...
The err part is Capitalized in the code, it also comes in foreaching. Because of the abstract list, it cannot be initialized, declaration is in a static field. The lists have the same type.
import java.util.*;
public class Test
{
public static final List<String> highPrio = Arrays.asList("*","/");
public static List<Str...
a=[1,2,3,4]
b=a.index(6)
del a[b]
print a
it show error:
Traceback (most recent call last):
File "D:\zjm_code\a.py", line 6, in <module>
b=a.index(6)
ValueError: list.index(x): x not in list
so i have to do this :
a=[1,2,3,4]
try:
b=a.index(6)
del a[b]
except:
pass
print a
but this is not simple,has any simply w...
Hello, I have just started learning Haskell and have got stumped on how to add a rating to a custom data type.
The data type I'm using has a name, a year and a tuple (userName and their rating), it looks like:
data Wine = Wine String Int [Rating] deriving (Eq,Ord,Show,Read)
type Rating = (String, Int)
I wanted to allow a user to rate...
I have the following Java code:
import java.util.Arrays;
import java.util.Collections;
public class Test {
public static void main(String[] args) {
int[] test = {1,2,3,4,5};
Collections.rotate(Arrays.asList(test), -1);
for(int i = 0; i < test.length; i++) { System.out.println(test[i]); }
}
}
I want th...
hi all,
i am trying to make an unordered list to behave in different browsers.
i have a 2 level list which i am trying to display horizontally in one line.
on safari and firefox everything looks good. on IE (7) everything goes nuts for some reason, and only when i am trying to make the list go right-to-left.
when i try displaying it left...
Hi Everyone,
At my site - jasondaydesign.com. I'm using easylistsplitter.js. I designed it this way, because I actually wanted a masonry.js style layout but I couldn't find a way to filter divs. So I made the switch to lists, and found a plugin that allowed me to have a masonry style layout.
Unfortunately, I have tried several list fil...
Hello,
from some code I found in Sacha Barbers free mvvm framework chinch I saw this:
return new DispatcherNotifiedObservableCollection<OrderModel>(
DataAccess.DataService.FetchAllOrders(
CurrentCustomer.CustomerId.DataValue).ConvertAll(
new Converter<Order, OrderM...
I need a simple script that reads a number from POST (we'll call the value 'number'). It will be a three digit number that must range from the following:
301-340
401-440
501-540
601-640
701-740
801-840
If it doesn't fall in these ranges, I need to echo a message. How would one do this?
...
If I've got a ul with 3 items in it and the list-style-type is set to lower-alpha, I end up with this
a. Item 1
b. Item 2
c. Item 3
With jQuery, I can easily get the value of any item you click - "Item 1" if I click the first. But can I get the list item label? In this case a?
...
<ul>
<li><a href="#">one</a></li>
<li><a href="#">two</a></li>
<li><a href="#">three</a></li>
</ul>
I'd like to show only one li at a time using slide effect, thats it. I'd like to avoid using plugins for something as simple as this.
Thanks in advance for your help.
...
For example, if I have a string a=123456789876567543 could i have a list like...
123
456
789
876
567
543
...
Is there a good method of storing a list of rows in a cell and then detecting whether a certain row is in that list?
The method I have seems a bit over the top. I label each row with a prime number, then store the list of rows as the product of each prime, missing out the rows I don't want in my list.
Detecting whether a given row is...
I want something like this:
public void CopyIteratorIntoList(Iterator<Foo> fooIterator) {
List<Foo> fooList = new ArrayList<Foo>();
fooList.addAll(fooIterator);
}
which should be equivalent to:
public void CopyIteratorIntoList(Iterator<Foo> fooIterator) {
List<Foo> fooList = new ArrayList<Foo>();
while(fooIterator.has...
I'm trying to get this resolved in .NET 2.0 and unfortunately that is not negotiable.
I am reading in a csv file with columns of data that 'should' correspond to a List of tickers in IdentA with some modifications.
The csv file columsn would read:
A_MSFT,A_CSCO,_A_YHOO,B_MSFT,B_CSCO,B_YHOO,C_MSFT,C_CSCO,C_YHOO
IdentA[0]="MSFT"
IdentA[1...
this is my method: GetListItemsPainted<T>(List<T> list)
and i don't know what type is that list of,
how can i create new list that would have the passed list type?
something like this:
List<list.GetType()> newList = new List<list.GetType()>();
how can i cast my list to the real type so i would have all his properties etc.?
thanks
...