Questions tagged [list]

44576 questions
1

votes
0

answer
29

Views

Adding n different lists to list results same list repeating [duplicate]

This question already has an answer here: List of lists changes reflected across sublists unexpectedly 12 answers How to clone or copy a list? 20 answers When I add lists to my list the result is list of correct length, but all the lists are the same, last list I added code: cycle_points = [] for...
Arttu Hyvönen
1

votes
1

answer
72

Views

Get value from mpfr (R) generated list

I m trying the following part of my code. where I got numbers between 0 and 1, that I need for the rest of my calculations. V
ayoub essourni
1

votes
2

answer
278

Views

Find multiple max in a data (plot)

I have a list with Y values. If I plot it I get this: There are three dominant peaks visible. Question: Is there a way, in Python, to find the n-th most dominant spikes in a data list and print their x-position (in the list)? I need to take into account spikes with very small distance to each othe...
Paul G.
1

votes
0

answer
135

Views

How to supply multiple lists to 'lapply'?

My objective is to find svytotals of all the variables of a dataframe which contain the term 'INCOME'. I have to do this for multiple files. This is what I have done so far (thanks to stack overflow)- Code- library(sqldf) library(survey) filenames=list.files(path=mypath1, glob2rx('*2014*rev*.txt')...
user7844805
1

votes
0

answer
60

Views

Facing an error with IndexError: list assignment out of range

I don't know how to use Python as I've never learned it before. Hence, I require some help from the community if that is possible. I've been trying to code out a program that loops through every single cell in the stated column and tokenize it for it to be stored in an array. So far, the array hasn...
Andric Png
1

votes
1

answer
99

Views

How to set the responsive width of Polymer component inside `<iron-list grid>`

Consider the following code, where always has a fixed width of 200px inside Polymer Element Test Case iron-list-grid-calc-issue .content { width: calc(50% - 32px); /* Not working */ width: 200px; height: 200px; line-height: 200px; text-align: center; border: 1px solid grey; box-sizing: border-box;...
Andrew See
1

votes
1

answer
1k

Views

Ngx-Chips - Autocomplete list not updated after receiving response

I am using ngx-chips plugin in my project. Now the dropdown list is populated using Http call to server. myContactList data is updated on view as well but I cannot see the dropdown. If I type some text again the list shows up. But the list is old one not the data of latest request. These is also one...
Sangwin Gawande
0

votes
0

answer
11

Views

Failing to remove the first node in a LinkedList

I am practicing using Java's LinkedList. The purpose of the main method here is to remove the given index's node. The given node can be removed rightly, except the first node. If I changed removeLastKthNode(head, lastKth); into head = removeLastKthNode(head, lastKth), it works. But I don't know wh...
tao4free
1

votes
1

answer
24

Views

How to fix remove node and go to last node after?

I am having trouble removing a node from the user input and properly going to the last node, so it will be ready to add a new node after. I am refactoring this code to a larger implementation. However, I am unable to remove the node and go to the last node after. This is also using user input to fin...
Morris Zieve
0

votes
1

answer
13

Views

A Simple `paste0` Command is Not Working Within a `draw` Command? (ComplexHeatmap, r)

As part of using ComplexHeatmaps, I need to create a string which will allow me to plot three maps together. If I have heatmaps A, B and C, I will need to do this, AllMaps
Solebay Sharp
0

votes
0

answer
8

Views

How to fix this selection sort logical error?

i am trying to implement selection sort but it doesn't pan out the same way as said in algorithm did I do something wrong with assignment operators? def selection_sort(list_1): for i in range(len(list_1)): val = min(list_1[i:]) list_1[i],list_1[list_1.index(val)] =list_1[list_1.index(val)], list_1...
psyduck
1

votes
1

answer
57

Views

Append counted value for a list of values

The following program works exactly as intended: destinations = {} while True: query = input('Tell me where you went: ').strip() if not query: break if query.count(',') != 1: print('That's not a legal city, state combination. Please try again.\n') continue city, country = query.split(',') city = cit...
MarkS
1

votes
1

answer
46

Views

Not able to use a list in a if-statement

I'm trying to make a loop that allowed me to retrieve tokenized data values in a list, check if there's stop words inside the tokenized cell value and append it to a new list. # Importing the packages to be used import xlrd from nltk.tokenize import word_tokenize from nltk.corpus import stopwords #...
Andric Png
1

votes
2

answer
89

Views

Python3: Search List of tuples for values which have public IP addresses

I am attempting to write a script which pulls data from a sqlite3 db and outputs only specific data which is of interest. I have written a function: def get_ip(db_file): cur = con.cursor() cur.execute('select 'Computer Name','User', 'IP Address1', 'IP Address2', 'IP Address3', 'IP Address4' from Sep...
Ryan Horan
1

votes
0

answer
167

Views

ERROR TypeError: db.list(…).subscribe is not a function

import { Component } from '@angular/core'; import {AngularFireDatabase} from 'angularfire2/database'; import 'rxjs/add/operator/take'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { firesto: any[]; constructor...
user8547607
1

votes
2

answer
563

Views

C# using while loop to add item to List<t> [closed]

Turns out there was nothing wrong with the code, just forgot to start up the XAMPP server -_- I'm trying to work with Xamarin inside VS2017ENT to develop an Cross-Platform C# App. I have started a new project as an Master Detail usting .NET Standard Code Sharing Strategy. My goal is to fill up a Lis...
K. Tromp
1

votes
0

answer
32

Views

how to create list of given values in “a” usig python?

I have written a code which will give maximum value from all arrays.I want to store all these values in a single list but i am getting different lists of different values. how to create a single list of these values? import numpy as np import re import gdal import ogr from osgeo import gdal_array fr...
vigna purohit
1

votes
0

answer
207

Views

Dynamically remove a layer from a layer-list

I would like to remove/hide a layer in a layer-list during runtime. How do I do this? I built a solution that works, but it feels a bit hackish. I replace the desired layer with a transparent image: LayerDrawable layerDrawable = (LayerDrawable) res.getDrawable(R.drawable.ic_layer); Drawable digit =...
Morgoth
1

votes
1

answer
36

Views

Find Neighbors of Different Type in Carousel List for Pair of the Same Type (Circular List)

I have a collection that behaves like a carousel i.e.: the last item is followed by the first item. In this collection (List of IdentifiedAnimal), there is a pair of values that are always together (Mammals). They can be even the first and the last themselves. My goal is to find the nearest neighbo...
gcbs_fln
1

votes
1

answer
46

Views

Use user input and configfile to write to a new file

I am pretty new to coding, and I am attempting to have a user input words (zones). I want these to be put into a list that can be used to pull from based on the counter. The rest of the input is being pulled from a file and then then broken up using shlex.split. I'm then naming these linetokens and...
Dustin Burmeister
1

votes
1

answer
47

Views

Compute the list, and it's sublists in reversed order Prolog

I have a list formed of integer numbers and lists of integer numbers, and I want to compute the lists in reversed order (each sublist is reversed) %addToEnd(E:number,L:list,LR:list) %addToEnd flow model(i,i,o) addToEnd(E,[],[E]). addToEnd(E,[H|T],[H|TR]):- addToEnd(E,T,TR). %reverse(L:list,LR:list)...
Lorena Pop
1

votes
2

answer
83

Views

How to dynamically insert strings in my linked list?

My C program should read an input file and save it line for line in a linked list, then printing it. But when it's inserting the next line in the list, all elements in the list become the new element. Input: abc def ghi Output: ghi ghi ghi I'm not sure but my guess is that it's not correctly a...
Ben
1

votes
3

answer
102

Views

How to validate the length of nested tuple passed to a function?

I am building a function that accepts the list of tuples. For example: my_list = [ ('str1', 1, 11), ('str2', 2, 22), ('str3', 3, 33), ('str4', 4, 44) ] I want to create a function with definition such that it will ONLY accept the parameters with the size of each nested element as '3'. How can I de...
Tummomoxie
1

votes
0

answer
41

Views

Is there a reason why __all__ variable in __init__.py is defined as a list in Python documentation?

As one may read here - __all__ variable is described as a list. Is there a reason (or does it even matter) for choosing this type over tuple? Both options work but tuple seems to be more valid as immutable type.
Mnich
1

votes
3

answer
41

Views

Android layerlist drawable

I am creating a login layout for an app.For the background of the LinearLayout([email protected]+id/lgn_lyt) I tried to make it look like the image below.It looks fine in design editor,but in the device it look weird.The drawable I used is a vector image.Is it because of the vector image I used it coding mistake...
jobin
1

votes
1

answer
94

Views

How to serialize my own generic List?

I wrote a generic List type. How do I make the List serializable? My main concern is with the GetObjectData() method. The following is my List class with its methods. I have done XML serialization before with the List that is already available in C# but I just don't know what I should write in th...
Blopsrusher
1

votes
0

answer
75

Views

Manage contact list using Microsoft Graph

I would like to create/read/edit and delete contact lists (similar to Exchange category, where you can group multiple contacts) of Office 365 Outlook using the Microsoft API. I have went through the documentation and attempted to perform the actions above using Microsoft Graft Explorer. It seems lik...
Josh Pham
1

votes
1

answer
202

Views

Prolog - Towers Of Hanoi, outputting the “towers” as they are after each step

I have seen multiple questions showing the way how one could solve the Towers Of Hanoi question in Prolog with and without lists, however what I haven't seen yet is a way for one to use the recursive algorithm, while also being able to output each step. Here is my code of the Hanoi algorithm: move(1...
MasterTextman
1

votes
1

answer
28

Views

print elements in list in reversed order and on a new line

I want to print all elements in this list in reversed order and every element in this list must be on a new line. For example if the list is ['i', 'am', 'programming', 'with', 'python'] it should print out: python with programming am i What is the best way to do this? def list(): words = [] while Tr...
bhr
1

votes
1

answer
89

Views

Using for / list comprehension for creating a tuple from any amount of other tuples

With the following code I'm looking at how to create the TRACKS[0] and ARM[0] tuples (or even a whole set, e.g. ARM), as they are very similar - I think something like a list comprehension would work (as I'm picturing a for each loop). # MOTORS: all, m1, m2, m3, m4, m5 (+, -) MOTORS = ( ( (0b0101010...
zimchaa
1

votes
1

answer
112

Views

C++ Swapping adjacent nodes in a linked list

I'm having some trouble swapping adjacent nodes in a singly linked list. Here's my swap function: void swap(std::shared_ptr root, int indexA, int indexB) { if (indexA == 0) { std::shared_ptr A = root; std::shared_ptr B = A->next; A->next = B->next; B->next = A; root = B; } else if (indexB == 0) { st...
Alexander Granell
1

votes
0

answer
124

Views

Large number division with linked lists in C

I am trying to represent a string that holds any number to infinity. This number must be an integer and return its value as a result. Right now, my goal is to do this representation but for division only. So lets say we have 125 as our numerator, and 5 as our denominator. The answer should be 25 rig...
Zeid Tisnes
1

votes
1

answer
70

Views

how to validate list in web api

I am writing a web api which accepts list of customers in from file upload. Each row in file represents single customers. There can be 'n' customers in a single file. For each row, validation check is required. The error messages needs to be displayed in respective row. POST /api/customers List if...
Vijay Balkawade
1

votes
2

answer
34

Views

Convert a dictionary of lists to two-column csv

I have a dictionary of lists as follows: {'banana': [1,2], 'monkey': [5], 'cow': [1,5,0], ...} I want to write a csv that contains one number and word as follows: 1 | banana 2 | banana 5 | monkey 1 | cow 5 | cow 0 | cow ... with | as the delimiter. I tried to convert it to a list of tuples, and w...
quinn
1

votes
1

answer
209

Views

write lists to pandas dataframe to csv, read dataframe from csv and convert to lists again without having strings

Originally I had a list of list and each list contains tuples of strings (from some computations). I want to save them for later, so I don't have to do all the computations again and just read the csv. L = [l1,l2,...] l1 = [('a','b'), ('c','d'),...] l2 = [('e','f'), ('g','h'),...]... I converted it...
Philipp
1

votes
0

answer
77

Views

Sorting and editing a Dictionary in Python

I use the CCL algorithm of Spencer Whitt from Github to remove detected road markings from Noise. First, I run the CCL algorithm over an image so that it recognizes contiguous elements. Now I extended the algorithm so that it ignores elements with a small number of pixels. So I tried to sort and fil...
freddykrueger
1

votes
2

answer
53

Views

How to display in one line that have many behavior in LinkedList

Our prof gave us an activity about creating a linked list with another class that has attributes or behavior of last name, first name, age, course, etc. So my question is if I set a cumulative setter with the following given attributes. if I add it to the linked list will the linked list itself will...
genkisan
1

votes
2

answer
382

Views

Passing a slice to recursive function in Python

I think I understand the basic principles of recursive functions and slicing (individually), but I am having trouble putting them together. I don't understand what happens when you pass a slice or a list to the following function. def listSum(ls): # Base condition if not ls: return 0 # First element...
jeffrlynn
1

votes
2

answer
25

Views

how to bring the list I created in class as a parameter in new function

I'd like to say my English is second language and sorry for any inconvenience to read or understand my post. I will explain what kind of code I produced first, So I created my class function using the code below class Histogram: def __init__(self, range , max_mark): self.__range = range self.__max_...
G.Lee159
1

votes
2

answer
185

Views

How to print a Java List to a Yaml List in brace ([ ]) format, using Jackson yaml

I am trying to find a way to print Java ArrayLists to Yaml lists, in the following format: [list-element1,list-element2,list-element3...] However,I have only managed to print them into Yaml lists in the alternative format: -list-element1 -list-element2 -list-element3 Is there a way that the first ca...
atsag

View additional questions