As title suggests, I had problems with a program of mine where I used a std::list as a stack and also to iterate over all elements of the list. The program was taking way too long when the lists became very big.
Does anyone have a good explanation for this? Is it some stack/cache behavior?
(Solved the problem by changing the lists to s...
I have the following mostly ok code:
my $results = { data => [
map {
my $f = $_->TO_JSON;
$f->{display_field} = $_->display_field($q);
$f;
} $rs->all
]};
Only I'd rather it were more like the following:
my $results = { data => [
map {
%{$_->TO_JSON},
display_field => $_->display_field($q),
},...
Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]
Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?
...
Hello,
is it possible to initialize a List with other List's in C#? Say I've got these to lists:
List<int> set1 = new List<int>() {1, 2, 3};
List<int> set2 = new List<int>() {4, 5, 6};
What I'd like to have is a shorthand for this code:
List<int> fullSet = new List<int>();
fullSet.AddRange(set1);
fullSet.AddRange(set2);
Thanks in...
I have a number of collections of classes which I need to refactor into new classes. I'm using Java with either Eclipse or Netbeans. Currently I create the new class FooList with a delegate List<Foo> and then follow all the places where the code fails to compile. Is there a way to do this without breaking the code (and preferably a singl...
Hi I'm having trouble compiling a simple piece of code. I am creating a class which implements a Deck of cards, and I want to create a shuffle method using the list::short method.
Relevant code:
deck.h
#ifndef _DECK_H
#define _DECK_H
#include <list>
#include <ostream>
#include "Card.h"
#include "RandomGenerator.h"
using namespace s...
I have a function whose input argument can either be an element or a list of elements. If this argument is a single element then I put it in a list so I can iterate over the input in a consistent manner.
Currently I have this:
def my_func(input):
if not isinstance(input, list): input = [input]
for e in input:
...
I a...
Hi folks,
I'm building a micro site at the moment and I have a problem. I want to scroll to the different list elements by clicking on my menu. This is working fine. But the problem is, by using the list index to traverse to the second or third element of mainmenu, its only working fine in the first menu because the index of the second...
Hello
I'm trying to think of a way to create a list of items that I can display on a webpage that my visitors can tick off, without ever having to log in.
The list may be like so:
[ ] Buy potatoes
[ ] Pickup kids
[x] Drink more water
[ ] Go for a Run
If User A visits the site, and clicks "Drink More Water" I want that to sav...
How can I create a new list via a feature in MOSS and also include new fields in that list?
I am currently using a node to create the list but I want some new fields in addition to the title field that appears with a new custom list.
...
I was having some trouble grokking the list comprehension syntax in Python, so I started thinking about how to achieve the same thing in Perl, which I'm more familiar with. I realized that the basic examples (taken from this page) can all be done in Perl with map or grep.
E.g.
(python) (perl) ...
Hey everyone,
I am trying to implement a Stack in java (using the list interface: Interface List).
I want to implement it two different ways: using composition and inheritance.
For inheritance, so far I have:
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public cl...
If I have defined the following types:
type category = Noun | Verb | Adjective | Preposition;;
type transformation = {start: category; fin: category};;
What is the best way to answer the question "is the record where start = Noun in the list of type transformation?
Sort of like
let un = [{start= Noun; fin= Noun}; {start= Verb; fin= ...
It seems that often __init__ methods are similar to this:
def __init__(self, ivar1, ivar2, ivar3):
self.ivar1 = ivar1
self.ivar2 = ivar2
self.ivar3 = ivar3
Is there someway to turn the arguments into a list (without resorting to *args or **kwargs) and then using setattr to set the instance variables, with the name of the p...
I googled all day and I cant find one good example how to map this kind of objects:
class Parent{
private Integer parentId;
private String parentName;
private List<Child> childs;
// ....... getters and setters ............
}
class Child{
private Integer childId;
private String childName;
private Parent par...
I have the following code
private Map<KEY, Object> values = new HashMap<KEY, Object>();
public void set(KEY key, Object value) {
values.put(key, value);
}
private Object getObj(KEY key) {
return values.get(key) == null ? key.getDefaultValue() : values.get(key);
}
public List<E> getList(KEY key) {
return (List<E>) getObj(key);
}
...
Is there any quick guide/reference to list all the countries and its states/provinces?
Like when I click US, it will list: Alabama, alaska etc
...
This works:
<hibernate-mapping>
<class name="Train" table="Trains">
<id column="id" name="id" type="java.lang.String" length="4">
<generator class="assigned" />
</id>
<set name="trips" cascade="all">
<key column="trainId"/>
<one-to-many class="Trip"/>
</set>
<...
I'm using this code to search trough about 500 li tags.
$(function() {
$.expr[":"].containsInCaseSensitive = function(el, i, m){
var search = m[3];
if (!search) return false;
return eval("/" + search + "/i").test($(el).text());
};
$('#query').focus().keyup(function(e){
if(this.value.length > 0){
$('ul#abbreviations li'...
Instead of specifying a int list or string list, could I specify a list whose members must be either strings or ints, but nothing else?
...