Questions tagged [list]

34711 questions
1

votes
2

answer
699

Views

needed: simple way to force json to decode to “normal” iterable python lists

I've stackoverflow a ton and never found the need to ask a question before, and while there are a lot of threads on this subject, I can't seem to find something that is easy and makes sense. If I have somehow missed something, please provide a link. Here goes: I am trying to pass lists back and...
domoarigato
1

votes
3

answer
5.4k

Views

convert a row of a data frame to a simple vector in R

I have a huge data frame from which I only select a couple of rows. Then I remove some of the columns based on a condition. let us say that I choose row 4460 as shown bellow: V1870 V107 V1315 V1867 V1544 V1207 V1252 V1765 V342 V429 V1826 V865 V1374 4460 0 0 3 0 5 0 2 0...
John
1

votes
4

answer
90

Views

Add object that called method to a list

I am trying to make a simple achievement class in C# + XNA, and I want to implement a queue so that when you get multiple achievements quickly after eachother, the latter will be added to a queue list. Here is the method that is being called to get a certain achievement: //This is the list that I wa...
Luca_Scorpion
1

votes
2

answer
107

Views

Saving Objects from an Iterated List

I'm currently workin' on a sales module using java+hibernate+oracle... I'm done with my order form in my jsp like this: I'm getting my parameters doing this: ArrayList idMercaderias = new ArrayList(); ArrayList cantidades = new ArrayList(); ArrayList precios = new ArrayList(); for (int k = 0; k < 10...
Felipe Rodriguez
1

votes
1

answer
101

Views

Importing lists from another file

Currently I am programming something that uses lists. These lists are quite large and I was wondering if I can put them in a separate python file. Then import them. For example List1 = [] List1.append("Blah") List1.append("Blah1") List1.append("Blah2") List1.append("Blah3") I'd like to have that lis...
0

votes
1

answer
39

Views

Looping over nested dictionary and delete if condition is not met (python)

I have a list of nested dictionaries: [{'a': 1, 'b': 'string', 'c': [{'key1': 80, 'key2': 'string', 'key3': 4033}, {'key1': 324, 'key2': 'string', 'key3': 4034, 'key4': 1}]}, {'a': 1, 'b': 'string', 'c': [{'key1': 80, 'key2': 'string', 'key3': 4033}, {'key1': 324, 'key2': 'string', 'key3': 4034, 'ke...
rororo
1

votes
2

answer
23.3k

Views

Linked Lists. Head and Tail References

Im trying to make an Add and Delete method to my linked list class. I made 2 references with the names Head and Tail. Head -> 1 -> 2 -> 3 -> Tail:null I keep getting problems when I try and delete specific nodes because Java says I'm out of bounds. I think it is because my Head isn't pointing to th...
Bob
1

votes
3

answer
646

Views

Add to list if not already in list, change elements in list (PROLOG)

I am new to Prolog and I am trying to write a function that checks to see if a given key is in a list; if it is, it will increment the value in the list, otherwise it will append to the end of the list. Here is my code so far. placeKey( Key, [] , List2 ) :- append(Key,[], List2). %base case:...
user3055170
1

votes
3

answer
339

Views

Prolog sum of a list of numbers

I am new to Prolog and I want to write poppler(Nums, Plate, Tastiness) that takes a list of exactly 9 numbers as input, and, if possible, returns a permutation of those numbers that forms a delicious poppler plate when Plate is read in row-major format. A Poppler plate is said to be delicious if the...
MicM
3

votes
1

answer
36

Views

Python: Converting a linked list to a list using a list comprehension?

Let's say I have a simple linked list implementation using a dictionary called child that associates a node with the following node in the linked list. For example a->b->c->d would be {a:b,b:c,c:d,d:None} Converting this to a normal list is trivial, myList=[] node=a while node!=None: myList.append...
Conor Henry
1

votes
1

answer
23

Views

How to convert a file containing a list of lists to a string?

I have a text file with the following content [['server', ' working'], ['android', ' working'], ['using', ' could']] From this .txt file I want to ouput another .txt file with content server, working android, working using, cloud with an empty line between them. I have tried this text_file = 'str_...
Samuel Mideksa
2

votes
1

answer
16

Views

Python - local variable keeps content repeatedly called function

I have the following example: def some_function(input1, some_list=[]): if some_list==[]: some_list.append(input1) if input1 % 3 != 0: some_list.append('last_one') else: some_list.append(input1/3) some_list = some_function(input1/3, some_list) return some_list def main(): #first call print(some_funct...
Egirus Ornila
0

votes
2

answer
17

Views

How to turn a <nav> with lists into a dropdown menu

I am having trouble turning my nav into a drop down menu. I have tried many ways, yet I am not able to turn my nav into a drop down menu. I don't understand what I am doing wrong. The solutions I am trying look like the guides I tried following. To no luck. Here is my code. HTML Menu Fighting Kites...
John Doee
0

votes
0

answer
22

Views

Efficient way to randomly select all rows from pandas dataframe corresponding to a column value

I have a pandas dataframe containing about 2 Million rows which looks like the following example ID V1 V2 V3 V4 V5 12 0.2 0.3 0.5 0.03 0.9 12 0.5 0.4 0.6 0.7 1.8 01 3.8 2.9 1.1 1.6 1.5 17 0.9 1.2 1.8 2.6 9.0 02 0.2 0.3 0.5 0.03 0.9 12 0.5 0.4 0.6 0.7...
iprof0214
1

votes
0

answer
12

Views

SP Checkbox Selection Cleared After Closing Browser

I have a Settings page which have some checkbox settings as follow: In my development environment, the selections stay even after reopening the browser. However, when I bring it to a live environment, the checkbox are cleared after closing and reopening the browser. The program runs fine. Just that...
gymcode
1

votes
2

answer
509

Views

How would you evenly distribute a list of sublists that each have a numerical value across three lists?

How would you evenly distribute a list of sublists that each have a value? I'd like to distribute the following list into 3 lists. lst = [['a',10],['b',40],['c',10],['d',30],['e',20],['f',100],['g',90],['h',4]] Since the aggregate of all the values is 304, the three lists should aggregate to about...
Chris
1

votes
1

answer
1.6k

Views

List All Text Files in a Directory with more than 100 Lines using PowerShell

Hello I'm PowerShell beginner. I'm looking for a script which finds and list all text files in a directory (*.TXT) with more than 100 lines. This code show max and min number of lines in a directory but doesn't list files with min or max number of lines. dir . -filter "*.txt" -Recurse -name | foreac...
john
1

votes
2

answer
850

Views

Finding the nth element of a list in scala recursively with pattern matching

I have a problem here from 99 scala problems (http://aperiodic.net/phil/scala/s-99/p03.scala) that I am trying to figure out how it works. I'm fairly new to Scala. I was able to complete this challenge with a similar solution using pattern matching and recursion however mine did not consider the lis...
user3789100
1

votes
4

answer
55

Views

How to take multiple lists and nest them?

Currently working with a text file that is read into python and then must be made into lists with a list (nested I guess?) So far I've tried double splitting the file but to no avail. This is what the reader code looks like: def populationreader(): with open("PopulationofAnnecy", "r") as in_file: fo...
Johnathan Scott
3

votes
2

answer
19

Views
0

votes
2

answer
27

Views

Count how many times a value appears in dictionary ? (PYTHON 3)

Suppose i have a list of names like this: names = [ 'James','Bruce','John'] and a dictionary like this: dict= { 'James':{ 'Job' :'Engineer'}, 'Bruce':{'Job' : 'Engineer'}, 'John':{'Job' :'Doctor'} } I want to create a dictionary that count how many times 'Doctor' or 'Engineer' appear in...
Tony Le
1

votes
1

answer
138

Views

Update Sharepoint 2013 using Python3

I am currently trying to update a Sharepoint 2013 list. This is the module that I am using using to accomplish that task. However, when I run the post task I receive the following error: "b'{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","val...
1

votes
4

answer
74

Views

List with two elements

I have a list public List UList = new List(); UList.Add(new string[] { "veeru", "basanti" }); UList.Add(new string[] { "jay", "radha" }); UList.Add(new string[] { "gabbar", "ramlal" }); How do I search in the list if the pair of 'veeru' and 'basanti' exists? I want something like - if(pair exis...
jrk007
1

votes
2

answer
91

Views

c++ An Array/List of differing classes

I haven't done much polymorphism in c++, and it's been a long time since I done it in other languages, so I'd like some input as to if what I'm trying to achieve is even possible. I have a class "Entity", and several other 'specialized' sub-classes which inherit Entity. These sub-classes all have co...
Yattabyte
1

votes
3

answer
63

Views

Trouble while modifying a pointer within a C function

Hi I'm trying to implement a liked llist operation in C. My approach is to implement all operation in a header C file, and to include it in a main file to manage linked lists. Here is the header file linkedlist.h, containing operations implementations //Here is my code for the node structure: struct...
Fopa Léon Constantin
1

votes
2

answer
17

Views

Lookup Values in Named List to Replace in another Named List in R

I have a list of coded answers to a survey, along with a codex which has each possible coded answer to a particular question in said survey with the actual answer stored with it. The data is set up as a list, which is built something like this for context: mylist=list(a=list(AA="Yes",AB="No",AC="May...
Thomas Campbell
1

votes
1

answer
61

Views

Sum a list of arrays

I have a large list of arrays of the same dimension: a
user1723765
1

votes
2

answer
503

Views

Why is clear an O(n) operation for linked list?

According to attachment 1, linked list's clear operation is O(n). I have a question about why is it so. Here is how we implemented the linked list in class(java) public class LinkedIntList { private ListNode front; ...... } And if I were to write a clear method for this linked list class, this is h...
committedandroider
1

votes
2

answer
414

Views

how to list data types from a document in couchdb

Is there any opprtunity to list all data types of a document in couchdb like string, object,integer ? I'm using only curl with a Windows machine.
Relaxo
1

votes
2

answer
338

Views

Wolfram Mathematica: How can I copy list without only one element?

E.g. I have list A = {a,b,c,d} How can I get list B = A without {b} element in one command?
1

votes
4

answer
3.4k

Views

How do I convert a text file into a list then sort it with Python?

I have a text file with the following lyrics: 'First verse Im off till I'm off the island i'm riding like autoban on autopilot before I touch dirt I deal you all with kindness my natual persona much worse' I want to convert it to a list, then sort it alphabetically, but what I keep getting is: [[Fir...
MikeT
1

votes
7

answer
1.5k

Views

Java to sort list of custom object on the basis of string

class Person { private String name; private String profession; } profession has values: engineer Doctor Teacher student I have list of person and want to sort it on the basis of Profession. engineer comes first then Doctor and then Teacher and then student. Is it possible to sort it with comparabl...
user3586231
1

votes
1

answer
1k

Views

Iterate Generic List of Strings (Lync chatroom members) in Powershell

I can't iterate through a Generic List of Strings in Powershell. The Object is the members of a Lync chatroom. Command to get the Generic List: $crMembers = get-csPersistentChatroom -identity "XXXX" | select members The error I receive when trying to read the Strings in the Generic List is: WARNING:...
Plarsen
1

votes
2

answer
113

Views

Line by line check for large amount of keywords with python

I am iterating through many csv files with 1000 to 3000 lines checking each line whether one of 70000 key words is inherited in a text of 140 characters. My problem at the moment is, that my code runs extremely slow. I guess because of the many iterations. I am relatively new programer and not sure...
Justus Niemzok
2

votes
1

answer
40

Views

how to convert list of arrays of same legth

if I convert a list of arrays (the internal arrays have all the same length) in an array of arrays, python converts it as a matrix with all the elements joined together. I want it to always remain an array of arrays. Here's what happens: list_1 = [[np.array([1,2,3]),np.array([4,5,6])]] >>> np.array(...
BossShell
0

votes
2

answer
46

Views

Java performance : Java logic to find the 3 highest number from huge list [duplicate]

This question already has an answer here: Find the k largest elements in order 6 answers This was the question I was asked in an interview for checking the performance knowledge. Question - I have a list (Arraylist by default and if you wanna change the list then justify) of integers. There are mil...
DarkKnight
1

votes
2

answer
7.1k

Views

How do i access and object attribute inside a list of objects given certain index?

In other programming languages, to access attributes in of a class instance you just do: print(Object.Attr) and you do so in python as well, but how exactly you get a certain attribute at a certain index in a list of objects, normally i'd do this: ListObj[i].attr but the object is in a list. I want...
1

votes
2

answer
100

Views

PHP Array : a function that return next object in array (with array and current object param)?

My question is : is there a function that return next object in array (with array and current object param) ? Can you help me to code the best way ? function get_next($array, $currentObject) { .... ? return $nextObject; }
NIF
1

votes
1

answer
99

Views

Don't understand how method “delete” work in linkedlist

please help me to understand how do method delete(with specify value) work? I understood everything except this point. I wrote method delete but don't understand how changing field next in Link "previous" weigh with Link first, I know that the next Link will be missed, but this Link also will be mis...
1

votes
3

answer
3.1k

Views

Initiate a float list with zeros in C#

I want to initiate a list of N objects with zeros( 0.0 ) . I thought of doing it like that: var TempList = new List(new float[(int)(N)]); Is there any better(more efficeint) way to do that?
axcelenator

View additional questions