Category "for-loop"

What would cause a for / foreach loop to break without explicitly calling a break?

I have a durable function that calls a method that simply adds a row to an efcore object. It doesn't call db save. When I step through the code, and get to the

Using zipfile to archive directory contents while skipping files from list

I'm using zipfile to create an archive of all files in a directory (recursively, while preserving directory structure including empty folders) and want the proc

Print loop output horizontally?

Hey guys I have to write a program for class that asks me to produce a bar graph based on how many cars a salesperson sold for the month. An example is this: P

JS Find indices of duplicate values in array if there are more than two duplicates

I'm creating coordinate plane Three in a row game so I have to find out if there are three numbers of the same value in the array BUT WITHOUT sorting array beca

Sum of odd numbers until reached limit in Javascript

While I was solving a question saying "add odd numbers from 1 to 20", I coded this: var i, sum=0; for (i=2; i<=20; i*2){ sum=sum+i; } document.write(sum);

using cursor attributes in a CURSOR FOR LOOP

I am running the following in the Scott schema: SET serveroutput ON; BEGIN FOR c_Emp IN (SELECT * FROM emp) LOOP dbms_output.put_line('The record processed by

How to get the current index in for each Kotlin

How to get the index in a for each loop? I want to print numbers for every second iteration For example for (value in collection) { if (iteration_no % 2) {

How to get the current index in for each Kotlin

How to get the index in a for each loop? I want to print numbers for every second iteration For example for (value in collection) { if (iteration_no % 2) {

Loop ID through cells in Google Apps Script

Good Day! I would like the Purchase Order ID repeated upon submission of a form in an earlier sheet. My current code however repeats this throughout the length

Why is the vector subscript out of range?

I'm trying to code this really simple addition program for practice. It takes in a list of inputs and stores it in a vector. Then it grabs each consecutive elem

how to increment the iterator from inside for loop in python 3?

for i in range (0, 81): output = send command while True: last_byte = last_byte - offset if last_byte > offset: output = send comm

Not able to understand the output of this for loop in JS

I have understood why the output of this code should be 3 3 3. for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1); } I am not a

Iterate through a C++ Vector using a 'for' loop

I am new to the C++ language. I have been starting to use vectors, and have noticed that in all of the code I see to iterate though a vector via indices, the fi

How to use loops in JasperReports .jrxml file?

I am using iReport Designer to design the .jrxml file. How can I use the for loop or if loop in .jrxml file? Is it possible? If yes how?

Nested for loop in Big Oh Complexity

for(int i = 0; i < n; i++) { for(int j = 0; j < i; j++){ // do swap stuff, constant time } } I read that single for loop is O(N) and trav

Avoiding nested for loops

I am trying to do some parameter testing on another code using python. I need to test 6 independent parameters, but I need all of the possible combinations of t

onTap in GestureDetector is taking a value less, but Text is taking correct, both used in the same loop

In the following code, Text(subjects[address]) is printing the correct value, but GestureDetector( onTap: is taking the same value for the whole Row, and increm

Excel VBA - exit for loop

I would like to exit my for loop when a condition inside is met. How could I exit my for loop when the if condition has been met? I think some kind of exit at t

Create a new line whenever an array value reaches more than 10 characters

Here is my code, but it isn't dynamic. What I need is it will automatically create new line if array value is greater than 10. <?php $limit = 10; $newline =

Using Big O Notation, what is the correct label for this algorithm?

I am curious. What is the correct way to describe this using Big-O Notation? var prices = [100, 180, 260, 590, 40, 310, 535, 10, 5, 3]; var biggest_profit = 0;