Questions tagged [iteration]

-1

votes
0

answer
16

Views

How to iterate over a loop

I would like to do this automatically instead of typing it out 1500 times. n1
mymymine
1

votes
1

answer
757

Views

Have Two iteration in Current Scrum TFS

I want to know is it possible to have two or more iteration in current section for scrum in TFS. for example for one team with different Date can I have 2 or more iteration . also can I add some new field to my Epic. For Example Name of my Customer.
Mishaa
1

votes
1

answer
55

Views

Square root loop in python

I need to take an input of a number greater than 2, and take the square root until the square root is less than two. I need a print statement that includes the count of the times the square root of the number was taken as well as the output. What I have so far is: import math input_num = float(input...
Europa14
1

votes
1

answer
58

Views

Go to specific element C

I want to use a for loop to iterate through vector and when a certain condition is met, I want to go back to a certain element of vector and restart the loop from there. For example, let's say that my vector is 1,2,3,4,5,6,7,8,9; and when the first element that is bigger than 5 is met, I want to res...
Xyz
1

votes
4

answer
78

Views

How can I save the 'previous' and 'next' iteration of an object in a loop?

I am working on a program that grabs a number before, and after an incidence of a string and then compares those numbers - but it can only happen if the incidence of that string is there. I've tried iterating through the object.keys (maybe I didn't understand how correctly) I've tried nesting loops...
Jason Harder
1

votes
1

answer
35

Views

Get value from iterator.first

I've started a little toy project as a way to teach myself C++ and have hit a wall. In the code below the highlighted line is causing a build error saying: welcome.cc:65:26: error: cannot convert 'std::_Rb_tree_iterator >' to 'char' in assignment current = result.first; and I'm not sure why. The g...
MrB
1

votes
1

answer
22

Views

Reading corresponding lines from 2 text files with 2 foreach() loops

Needing to pull 2 objects from 2 different txt files, 1 getting the user id and the other the rule id. The line numbers should correlate to each other from both text files. The issue is the 2 foreach() loop, the outer one runs once and the inner one run for each rule id in the txt, problem is I dont...
mjzach22
2

votes
0

answer
12

Views

Solving eigenvectors/eigenvalues of sparse matrix in different ranges successively

I'm looking for eigenvalues/eigenvectors of a huge sparse matrix A (250k*250k) that lie in different eigenvalue ranges without calculating all the eigenvalues in between since it would just take too much time. My consideration was Step1: I'm trying to find k certain eigenvalues/eigenvectors of the m...
Allbrightable
0

votes
0

answer
6

Views

program not recognizing multiple occurrences of word python (on linux)

I'm making an essay generator by creating a directed graph from sample text where the words are nodes and there are directed edges between a word and any word that follows it. I'm forming the nodes through a dictionary, but the program doesn't seem to read occurrences of a word after the first. tH =...
viperclan
1

votes
2

answer
24

Views

Mapping item in a list to a list of lists

I'm thinking of an efficient way to map names in a list to grouped index items in a list of lists. Let's say I have this grouping: g = [[0,1],[2]] I also have this list: names = ['canine', 'dog', 'feline'] I want to return the mapped names to the grouping according to index: result = [['canine','dog...
djennacs
1

votes
1

answer
39

Views

PHP Get every Nth item in loop but group them by sets of 6

I am using Slick Slider to build a slider of events. Each 'slide' consists of a group of 6 events of different sizes (shown in the picture below): PHP: Slick Slider JS: $('#eventsList').slick({ dots: true, arrows: false, infinite: true, slidesToShow: 1, slidesToScroll: 1 }); This code works fine if...
cpcdev
1

votes
2

answer
94

Views

List<string> declaration speed differences in debug mode

I have created a small benchmarking console app for C# using the System.Diagnostics.StopWatch class to observe how long 3 methods take: How I run the Benchmark: public void Run() { Stopwatch sw = new Stopwatch(); sw.Start(); InitDirectly(); sw.Stop(); Console.WriteLine($'InitDirectly: {sw.Elapsed.To...
Csharpest
1

votes
2

answer
41

Views

Convert recursive function to iterative function

Although this may seem like a duplicate (maybe it is but I haven't found a solution to this version of the problem yet), I don't think it is. Below is my recursive function which blows python's recursion limit and I'd need to make it iterative instead but I'm having issues seeing how it could be pos...
Max Michel
1

votes
2

answer
52

Views

Is using Pattern/Matcher more efficient than looping through a string and looking for characters?

I am working on a project that will look through a java file for a particular method, and output the lines that method occupies to a file. I am already using a Pattern and Matcher to find the method, but then I iterate through characters in a line to find matching curly braces. My question is, woul...
Chandler Davis
1

votes
2

answer
50

Views

How to loop through Lua table using key, value, and index

I want to loop through a table that looks like this function add(t, k, v, ...) if k ~= nil then t[k] = v t[#t+1] = k return add(t, ...) end return t end my_table = add({ }, 'a', 5, 'b', 4, 'c', 3) for i,k in ipairs(my_table) do local v = my_table[k] print(k, v) end Result: a - 5 b - 4 c - 3 But I wa...
Bunny
1

votes
2

answer
45

Views

Dynamically responding to an unpacking assignment statement

In an unpacking assignment statement, can the assigned object inspect the number of variables it is being assigned to? class MyObject: def __iter__(self): n = some_diabolical_hack() print(f'yielding {n} vals') return iter(['potato']*n) Something like: >>> x, y = MyObject() yielding 2 vals >>> a, b,...
wim
1

votes
0

answer
306

Views

Print Loop results of each iteration

I am working with CTM for Text Mining and I'm running a loop to define the optimal number of topics, using the following code: best.model
Pedro Oliveira
1

votes
1

answer
160

Views

Iteratively (re)naming node and edge attributes in NetworkX (python)

There is lots of information on this in terms of one-liners that add one node/edge/attribute, but I am looking for loops or the like that allow me to assign 100 nodes (as well as edges eventually) with attributes. For instance, having graph G, containing 100 nodes I would like to give each node a va...
nick88
1

votes
0

answer
49

Views

Not achieving convergence in iterative algorithm from paper

I am trying to implement Algorithm 6 (and eventually Algorithm 7) of the following paper - https://arxiv.org/pdf/1610.03045.pdf Most of this seems fine but I don't understand why I am not achieving convergence in the $z$ variables. My code seems to fit with what is written in the pseudocode for Alg...
Charlie Dickens
1

votes
1

answer
42

Views

standardizing a value, iterating over a groupby object

I need some help iterating over a groupby object in python. I have people nested under a single ID variable, and then under each one of those, they have balances for anywhere from 3 to 6 months. So, printing the groupby object looks, for example, like this: (1, Primary BP Product Rpt Month Cl...
lucretiuss
1

votes
2

answer
72

Views

Loop for a string with inbuilt macro with multiple validations

I am fresh to VBA. Therefore have difficulties of getting some essential things out of code. I have a macros written for two strings. The first string is a string with values I am validating, and the second string, following the first one, is full with validation messages. What I need to do is built...
inconsistent
1

votes
1

answer
149

Views

Looping through multiple lists in parallel and temporarily looping through only one list

TL;DR: I'm trying to write a FIFO method calculator for accounting purposes, which iterates through two lists simultaneously (where each list is a collection of buy orders or sell orders, and each element of each list represents an individual order). In Python, is there a way to loop through two seq...
mjl
1

votes
2

answer
189

Views

React iterate through an object inside of an array in JSON

I am working on a React project and attempting to pull JSON data from an API. I have a searchbar and I want to make it so the user can type a term into the searchbar and then that term is sent to a NASA API and returns the appropriate results. The NASA API looks like this. It has an array of objects...
Nick Kinlen
1

votes
1

answer
1.2k

Views

Access Object inside Array in React JSON API Call

I'm making an API call that returns JSON data in a React app. The data contains an object nested inside an array. I want to access the data within the object. I am able to access and iterate through the array data and log it with this: loadSearchResults = (event) => { event.preventDefault(); var sea...
Nick Kinlen
1

votes
1

answer
190

Views

How to loop through a nested JSON object and save the multiple key-value pairs in Javascript

I have an interesting issue, and I have the logic of the problem down but I am not having luck coming up with a solution. Basically, I have JSON objects (which could be of any shape or size) similar to the one listed below: { 'keyHigh': { 'title': 'Sign In Page', 'key2': { 'keyA': 'Hey!', 'keyB':...
Bean
1

votes
0

answer
28

Views

Image Transformation Without Loop

I am writing image transformation function in matlab instead of using predefined functions like 'imwarp or imtransform'. I am done with writing the code roughly but it is taking too long due to the use of loop. Please suggest me a solution which can achieve the same result without loops function I2...
Talha Khan
1

votes
0

answer
107

Views

Point Cloud Library Undefined symbols for architecture x86_64

i'm trying to do an iterative closest point but since I'm a noob I'm trying starting from this tutorial: http://pointclouds.org/documentation/tutorials/iterative_closest_point.php all required dependencies are installed, Operative System is MacOs High Sierra, I have this error when I execute make c...
Valerio M
1

votes
0

answer
35

Views

Python3.6: Use import os, iter and next to print directory of files with the same extension

Python 3.6 import os files = os.open('dir *.py') file_iter = iter(files) print(next(file_iter)) #Output: Volume in drive C is c However when I use a for loop: for file in files: print((file), end='') it seems to work fine. would anyone be able to help here please?
notabot62
1

votes
0

answer
113

Views

Clean and efficient way of iterating over ranges of indices in a single array

I have a contiguous array of particles in 3D space for a fluid simulation and I need to do a lot of neighbor searches on it. I've found that partitioning the search space into cubic cells and sorting the particles in-place by the cell they are in works well for my problem. That way for any given cel...
patatahooligan
1

votes
1

answer
153

Views

Is Monte Carlo Tree Search policy or value iteration (or something else)?

I am taking a Reinforcement Learning class and I didn’t understand how to combine the concepts of policy iteration/value iteration with Monte Carlo (and also TD/SARSA/Q-learning). In the table below, how can the empty cells be filled: Should/can it be binary yes/no, some string description or is i...
Johan
1

votes
0

answer
34

Views

Parsing Json in Filemaker iteration overwrite

I copied this json parsing script from here: https://fmhelp.filemaker.com/help/16/fmp/en/index.html#page/FMP_Help/json-functions.html#ww1155222 filemaker json parsing script: Set Variable [ $ProductCount ; Value: ValueCount ( JSONListKeys ( $$JSON ; 'bakery.product' ) ) ] Set Variable [ $i; Value: 0...
Dskip1199
1

votes
2

answer
31

Views

how to print data using the condition in python based on mysql result data

i have a mysql sample data resulting like below table main_cat| sub_cat | number | org_id Career | school | 5 | A Career | college | 3 | A Career | higher | 4 | A Job | Blr | 6 | A Job | Hyd | 11 | A Job | Chennai | 12 | A Career | school | 15...
1

votes
2

answer
121

Views

Generate isometric tiles from flat textures

Is there a simple tool (or code) to generate isometric tiles (cubes format) from using 1 or 2 (side/top) textures: For example taking Minecraft grass top and side texture: And generating a isometric result as: I have a folder containing all blocks textures (top and side if needed, blocks can be top/...
Retsim
1

votes
1

answer
61

Views

Regex javascript confusion from variable

I am mapping through a list of words (with random characters too) and the regex doesn't seem to work and ends up throwing an error. I basically have a const variable (called content) I want to search to see if there are certain words in the content variable. so I have if (list.words.map(lword=> { co...
thatdevopNB
1

votes
1

answer
39

Views

Filemaker if statement won't work

I have an if statement that is iterating through json data successfully but for some reason my if statement always reads as true when that shouldn't be the case. The result of this is the rest of my if statement isn't carried out so the data that I need to go to other fields is being reinserted in t...
Dskip1199
1

votes
0

answer
44

Views

Adding further properties to a function: timing and iteration improvement

I have a function written in python which does two procedures: Preprocessing: read in data from an array and compute some values that I will later need to prevent repeated computation Iterate and compute a 'summary' of the data at every stage and use this to solve an optimisation problem. The code i...
Charlie Dickens
1

votes
0

answer
60

Views

Laravel iterate through unlimited hierarchy treeview non-recursively

I have implemented printing a categories tree to the page recursively: foreach ($categories as $category) { $tree .=''.$category->title.''; if(count($category->childs)) { $tree .=$this->childView($category); } } $tree .=''; return view('categoryTreeview',compact('categories','allCategories','tree'))...
Ntel
1

votes
0

answer
72

Views

Netlogo Landuse Change modeling creating iterations

I'm using netlogo for a school project. This is the first time that I'm using netlogo and I'm running into some problems. For example I want to calculate a patch 'willingness to change' based on is they are with enough fellow patches according to a senario. I now wrote this: Ask patches [ if coun...
Roos de Boer
1

votes
1

answer
30

Views

Is it possible to iterate over a list of numbers in tsql?

I have a comma separated list of personIDs: 1265, 8632. What I want to do is something I'd like to indicate by a chunk of pseudo-code, which does not work, of course. declare @max int = (select count(*) from dbo.tablePersons)-1 declare @cnt = 0 BEGIN SELECT personID FROM dbo.tablePersons WHERE (126...
AF X
1

votes
1

answer
56

Views

Guidance: converting parallelly increamental nested loop to streams

I am trying to convert the following loop to Java stream. def a = [12,34,5,64,24,56], b = [1,23,45] for(int i=0;i y%2 != 0}).forEach({ y-> println x+','+y }); }); Output: 12,1 12,23 12,45 34,1 34,23 34,45 5,1 5,23 5,45 64,1 64,23 64,45 24,1 24,23 24,45 56,1 56,23 56,45
a.premkumar

View additional questions