list

IQueryable IGrouping how to work

i return such type IQueryable< IGrouping<int, Invoice>> List() how can i work with it? like with generic List<Invoice> ? ...

Does the List in .NET work the same way as arraylist in Java?

When I learned Java, I was told that the arraylist works this way: It creates an array with room for 10 elements. When the 11th element is added, it is created a new list with room for 20 elements, and the 10 elements are copied into the new array. This will repeat as until there are no more elements to add, or to a maximum size. Is ...

cast a List to a Collection

Hello, i have some pb. I want to cast a List to Collection in java Collection<T> collection = new Collection<T>(mylList); but i have this error Can not instantiate the type Collection ...

Redirect print in Python: val = print(arg) to output mixed iterable to file

So lets say I have an incredibly nested iterable of lists/dictionaries. I would like to print them to a file as easily as possible. Why can't I just redirect print to a file? val = print(arg) gets a SyntaxError. Is there a way to access stdinput? And why does print take forever with massive strings? Bad programming on my side for ...

In R, how to transform a matrix wtih 2 columns into a multimap like structure

Hi, I am wondering if there is a way to transform a matrix of 2 column into a multimap or list of list. The first column of the matrix is an id (with possibly duplicated entries) and the 2nd column is some value. For example, if I have to following matrix m<-matrix(c(1,2,1,3,2,4), c(3,2)) i would like to transform it into the follo...

List of Lists of different types

One of the data structures in my current project requires that I store lists of various types (String, int, float, etc.). I need to be able to dynamically store any number of lists without knowing what types they'll be. I tried storing each list as an object, but I ran into problems trying to cast back into the appropriate type (it kep...

Scheme how do you remove the first element from a list?

How do i remove the first element from a list in scheme say it looks something like '((apple bob car) (cat dig) (e))) how would i just get rid of "apple" and leave the rest alone? ...

Pass array to client side for display

Hey, I have an array which contains around 50-200 hyperlinks. How can I pass this array to the client-side so that I can iterate through the array and display each hyperlinks as a list item? The array will be stored in 'Application' as it's system wide and rarely changes. Could there be a more efficient way of achieving the hyperlinks a...

can the length of two xml lists be defined as being required to be equal?

Assuming you have two lists defined in an xml schema, call them A and B, is there a way to say A must be one or more items and B must be the same length as A? ...

How Does One Implements Lists in Domain Driven Design?

How does one implement lists such as a list of months in the year, or a list of years in DDD? Where does the logic go, inside value objects, a service, is it part of the domain layer? ...

List<> capacity has more items than added.

List <string> ali = new List<string>(); ali.Clear(); ali.Add("apple"); ali.Add("orange"); ali.Add("banana"); ali.Add("cherry"); ali.Add("mango"); ali.Add("plum"); ali.Add("jackfruit"); Console.WriteLine("the List has {0} items in it.",ali.Capacity.ToString()); when I run this the Console displays: ...

C# vs Java - Generic Lists

What are the differences of the C# and Java implementations of the generic List class? ...

Haskell, list of natural number

Hello, I am an absolute newbie in Haskell yet trying to understand how it works. I want to write my own lazy list of integers such as [1,2,3,4,5...]. For list of ones I have written ones = 1 : ones and when tried, works fine: *Main> take 10 ones [1,1,1,1,1,1,1,1,1,1] How can I do the same for increasing integers ? I have tried t...

Python: Inheritance of a class attribute (list)

Hi everyone, inheriting a class attribute from a super class and later changing the value for the subclass works fine: class Unit(object): value = 10 class Archer(Unit): pass print Unit.value print Archer.value Archer.value = 5 print Unit.value print Archer.value leads to the output: 10 10 10 5 which is just fine: Archer ...

Newbie Python programmer tangling with Lists.

Here's what I've got so far: # A. match_ends # Given a list of strings, return the count of the number of # strings where the string length is 2 or more and the first # and last chars of the string are the same. # Note: python does not have a ++ operator, but += works. def match_ends(words): counter = 0 for word in words: if len...

What exactly are tuples in Python?

I'm following a couple of Pythone exercises and I'm stumped at this one. # C. sort_last # Given a list of non-empty tuples, return a list sorted in increasing # order by the last element in each tuple. # e.g. [(1, 7), (1, 3), (3, 4, 5), (2, 2)] yields # [(2, 2), (1, 3), (3, 4, 5), (1, 7)] # Hint: use a custom key= function to extract th...

Trouble with this Python newbie exercise. Using Lists and finding if two adjacent elements are the same.

Here's what I got: # D. Given a list of numbers, return a list where # all adjacent == elements have been reduced to a single element, # so [1, 2, 2, 3] returns [1, 2, 3]. You may create a new list or # modify the passed in list. def remove_adjacent(nums): for number in nums: numberHolder = number # +++your code here+++ retur...

R: What's the easiest way to print out pairs of values from a data.frame?

I have a data.frame: df<-data.frame(a=c("x","x","y","y"),b=c(1,2,3,4)) > df a b 1 x 1 2 x 2 3 y 3 4 y 4 What's the easiest way to print out each pair of values as a list of strings like this: "x1", "x2", "y1", "y2" ...

How can I merge two lists and sort them working in 'linear' time?

I have this, and it works: # E. Given two lists sorted in increasing order, create and return a merged # list of all the elements in sorted order. You may modify the passed in lists. # Ideally, the solution should work in "linear" time, making a single # pass of both lists. def linear_merge(list1, list2): finalList = [] for item in ...

Passing empty list as parameter to JPA query throws error

If I pass an empty list into a JPA query, I get an error. For example: List<Municipality> municipalities = myDao.findAll(); // returns empty list em.createQuery("SELECT p FROM Profile p JOIN p.municipality m WHERE m IN (:municipalities)") .setParameter("municipalities", municipalities) .getResultList(); Because the list is em...