Questions tagged [for-loop]

A for loop is a control structure used by many programming languages to iterate over a range. It is a way of repeating statements a number of times until the loop ends. Depending on the language this may be over a range of integers, iterators, etc.

0
votes
0answers
27 views

C# How to loop through a list, update the same list, and continue looping?

I am writing a webscraper that grabs specific urls and adds them to a list.using HtmlAgilityPack;List<string> mylist=new List<string>();var firstUrl="http://example.com";HtmlWeb ...
-4
votes
0answers
14 views

Excel parser for .net [on hold]

need one help for finding technical approach for below requirement.Technical requirement:We have excel templates where business calculations are maintained in excel formulas.Template has 2 types ...
0
votes
0answers
23 views

Created directories from two lists

I have the following namedtuple and List:from collections import namedtuplefirefoxprofile=namedtuple("Profile", ["Name", "Path", "isRelative", "Default"])jb=firefoxprofile(Name='Jason', Path='...
0
votes
1answer
23 views

for loop with dplyr summarise returning different results than group_by

I'm getting strange results when applying for loop on dplyr summarise function - not sure why or how to fix it.test <- data.frame(title=c("a", "b", "c","a","b","c", "a", "b", "c","a","b","c"),...
0
votes
1answer
15 views

Python3 gives me KeyError when using a tuple as a dictionary key

the problem is that it's difficult to use the inputs as a key for the dictionary in a for loop , I tried to use tuple and list , but the same resulthere's the code :import remorse={"A" : ".-", ...
2
votes
0answers
17 views

Vectorizing a complex nested for loop in R (running models on different subsets of a data set, subsetting the data differently for each loop)

This is my first time posting so hopefully I manage to get my question across in a clear and concise manner.I am running a cross-validation experiment which involves training a model on a subset of ...
0
votes
2answers
20 views

#R - FOR loop - how to loop through every element of a vector in a column of a data.frame

The goals is to create a vector indicating if the student was absent(1), present(0), or if the data was missing(NA)Present <- data$attendancecodeattendance <- c()for (i in seq_along(Present)...
-8
votes
1answer
72 views

Getting bad performance in C++. What is wrong?

Why this code is taking 3.87 seconds in C++?#include <stdio.h>#include <time.h>int main() {int iterations=999999;int size=1000;int i,k;clock_t tStart=clock();...
0
votes
2answers
41 views

How do I create a 2d array in C++ that contains the counter of the loop in one part and a list of numbers in the other part?

I am trying to count the number of occurrences of a randomly generated number in 3 different cases: 10, 1,000, and 100,000 iterations. In each iteration, I would like to count the number of ...
0
votes
1answer
17 views

Optimization R loop when each iteration is dependent on the results of previous iterations

I need to optimize an R script. In particular, I need to speed up or delete some of the script's inundation cycles. I have defined many cycles of the type:DT <- data.frame("x"=c(1:20),...
0
votes
2answers
64 views

for loop is not working correctly after first loop [duplicate]

I wish to create a simple TicTacToe GUI Game by using Swing;I created JFrame called TicTacToe and put JPanel in it called gamePanel with GridLayout(3,3). Then I created a button array called buttons[]...
0
votes
1answer
14 views

Rvest web scraping gives open.connection error

I'm attempting to loop through a list of IDs to scrape some tables off Fangraphs. The below code works when I insert a single id and remove the for loop, but gives an error (i.e., Error in open....
1
vote
2answers
19 views

Accessing correct id in JSX for loop

I have the following code in React Native:render() {var rows=[];for (var i=0; i < 5; i++) {rows.push(<TouchableOpacity key={i} onPress={()=> console....
0
votes
0answers
10 views

How to write a for loop using Automata

I am interested to see how a for loop / while loop would be implemented as an automaton. I am having difficulty imagining how that would work. Say the while-loop did this:var i=0while (i < 10) ...
-4
votes
0answers
16 views

How to use a for loop and output #, in terminal, instead of numbers?

I want to create this in terminal using a for-loop:############################Please help??

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,