list

Python: How to remove /n from a list element?

I'm trying to get Python to a read line from a .txt file and write the elements of the first line into a list. The elements in the file were separated with a TAB so I used split("\t") to separate the elements. Because the .txt file has a lot of elements I saved the data found in each line into a separate list (data from the first lin...

Can i use a set or List in this example?

public class Student implements java.io.Serializable { private long studentId; private String studentName; private Set<Course> courses = new HashSet<Course>(0); public Student() { } public Student(String studentName) { this.studentName = studentName; } public Student(String studentName, Set<Course> courses) { this.studentName...

How to get All Dates in a given month in C#

Hello All , I want to make a function that take month and year and return List<DateTime> filled with all dates in this month. any help will be appreciated Thanks in Advance ...

Why won't the len() function output anything in python 3.1.2?

I installed the 3.1.2 IDLE python console, then I entered this code: >>> a = ['a', 'b', 'c', 'd'] >>> len(a) 4 Directly from the python official docs http://docs.python.org/py3k/tutorial/introduction.html#lists But it does not work in the interpreter as it should, it does not return 4. What am I doing wrong? Are the official docs wr...

Python style: for-in syntax, checking for empty lists and dictionaries.

I'm new to python and haven't yet read a lot of code to verify which styles are considered 'pythonic'. As I've started to code, I've been using this pattern alot. listThatMightBeEmpty = [] for items in listThatMightBeEmpty: print "this may or may not print but the loop won't cause any errors" I assume that it would be redundant t...

Java: Object Oriented Design; LinkedList and Stack

I am writing a BFS and DFS in Java. What I was hoping to do was create one class like this: /** Preforms BFS and DFS on ... */ public class Search{ private XXX toSearch; // where XXX is an interface of Stack and LinkedList that has // remove() and add() methods. public Search(boolean isBFS){ if(isBFS) toSearch = ...

css and jquery current links navigation problem?

i have this jquery code that retrieves external content using ajax, without refereshing the page, and i also have a navigation links that has the different background color when user is on the current page. the jquery code: function loadPage(url) //the function that loads pages via AJAX { url=url.replace('#page',''); //strip th...

splitting a list in jQuery - conscious of memory and reusability.

I'm trying to write a function in jQuery that will split lists - or really, any element that has children - that is conscious of memory use and is general enough to be widely reusable, but I'm having trouble resolving these against one another. For the sake of argument (and to keep the code on point) let's say I'm trying to split the li...

Create Lists from Character String

Hello all, Perhaps my brain is not working today but i cant figure out how to create a list from 2 character strings. I've currently got scale_lab [1] "Very Poor" "Poor" "Average" "Good" "Very Good" [6] "Don't Know" and scale_rep [1] "1" "2" "3" "4" "5" "9" So what I want to do is combine the two into a list so ...

Python -Intersection of multiple lists?

I am playing with python and am able to get the intersection of two lists: result = set(a).intersection(b) Now if d is a list containing a and b and a third element c, is there an built-in function for finding the intersection of all the three lists inside d? So for instance, d = [[1,2,3,4], [2,3,4], [3,4,5,6,7]] then the result sh...

C# custom list sorting...

Hello, I have a program that find all .csv reports file in a directory. This reports are stored in a List List<string> _items = new List<string>(); this reports are named like this: "month year.csv" (example: "Avgust 2010.csv") I would like to sort my reports by month. Months are in this order: januar, februar, marec, ap...

make a list out of a text file in java?

I have a text file full of numbers and I want to read the numbers into Java and then make a list that I can sort. it has been a while since I have used java and I am forgetting how to do this. the text file looks something like this 4.5234 9.3564 1.2342 4.4674 9.6545 6.7856 ...

Python: Replacing an element in a list of lists (#2)

A previous question with the same title as mine has been posted, with (I think) the same question, but had other problems in the code. I was not able to determine if that case was identical to mine or not. Anyway, I want to replace an element within a list in a list. Code: myNestedList = [[0,0]]*4 # [[0, 0], [0, 0], [0, 0], [0, 0]] myN...

Longest distinct consecutive list in Python

I have a list: a = [2, 3, 5, 6, 6, 7, 10, 11, 13, 14, 15, 16, 16, 17, 18, 20, 21] Is it possible to make a function that shows the longest list of distinct, consecutive elements? Please, show how to do it In this case the answer should be: 13, 14, 15, 16, 17, 18 ...

Is this possible using generics? c#

I know I can solve the following problem just by creating a custom class, but can the following be strongly typed as a List(or any other type)? var x = new object[] { new object[] { new Image(), new TextBox(), new FileUpload() }, new object[] { new Image(), new TextBox() , new FileUpload()} ...

CSS and/or jQuery to add little clickable image to multiple select list

I have a select list with multiple rows, and I want it to have a small X image at the end of each row so it deletes that row. Any idea how I can do that through CSS or jQuery or something?? Thanks ...

python - Creating multiple lists within a single Main List - Matplotlib table

Hi I am having problems with creating a matplot lib table using python. The example i have been following : http://matplotlib.sourceforge.net/examples/pylab_examples/table_demo.html My data : I have two for loops where in the first For loop i get the Protocol Name and in the second for loop i get the module name. I need the data to...

Custom reverse of a list in Prolog

Hello, I am trying to write a predicate that given the following list in Prolog: [[1,a,b],[2,c,d],[[3,e,f],[4,g,h],[5,i,j]],[6,k,l]] will produce the following list: [[6,k,l],[[5,i,j],[4,g,h],[3,e,f]],[2,c,d],[1,a,b]] As you can see I would like to preserve the order of the elements at the lowest level, to produce elements in the ...

Haskell List Reversal Error

Hi guys, I'm writing a list reversal program for haskell. I've got the idea for the list reversal and that has lead to the following code: myreverse list1 | list1 == [] = list1 | otherwise = (myreverse(tail list1)):(head list1) Unfortunately the above code results in the following error: Occurs check: cannot construct the...

Combining two lists of objects based on an attribute

Every example of list or set usage in Python seems to include trivial cases of integers but I have two lists of objects where the name attribute defines whether two objects instances are "the same" or not (other attributes might have different values). I can create a list that contains all items from both lists, sorted, with tmpList =...