nested-loops Questions

3

I am currently porting an algorithm from Java to Julia and now I have come across a part where I have to continue an outer loop from an inner loop when some condition is met: loopC: for(int x : Y...
Eph asked 7/11, 2016 at 15:39

5

Solved

I'm using Advanced Custom Fields for Wordpress and trying to loop a repeater inside a group. All I get is "Notice: Array to string conversion in..." What's wrong & how do I fix it? <?php i...
Aberration asked 28/8, 2018 at 12:0

16

Solved

If I use a break statement, it will only break inner loop and I need to use some flag to break the outer loop. But if there are many nested loops, the code will not look good. Is there any other wa...
Trivia asked 14/3, 2012 at 4:23

40

Solved

Given the following code (that doesn't work): while True: # Snip: print out current state while True: ok = get_input("Is this ok? (y/n)") if ok.lower() == "y": break 2 # Thi...
Rejoin asked 10/10, 2008 at 0:2

2

Solved

I want to run a loop in Ansible the number of times which is defined in a variable. Is this possible somehow? Imagine a list of servers and we want to create some numbered files on each server. Th...
Salesmanship asked 7/4, 2017 at 16:34

7

Solved

After researching a way to exit a nested loop, I decided to try using goto, private void example() { for (int i = 0; i < 100; i++) { for (int ii = 0; ii < 100; ii++) { for (int iii = 0;...
Lavonna asked 30/8, 2013 at 14:25

1

Solved

Let's say we have the following nested loop: MyClass myobject; for (const std::array<int,16>& arr : myobject) { for (int i : arr) { /* do something with i */ } } where MyClass can iter...
Promptbook asked 18/10, 2023 at 16:48

8

Solved

I am trying to make a christmas tree using for loops and nested for loops. For me to do that I need to be able to make a pyramids with *. I have tried countless times and I am having problems makin...
Klimt asked 9/6, 2015 at 4:50

24

Solved

Is it possible to use the break function to exit several nested for loops? If so, how would you go about doing this? Can you also control how many loops the break exits?
Gasiform asked 10/8, 2009 at 23:15

5

Solved

I just found out about using label s in JavaScript, such as: for (var i in team) { if(i === "something") { break doThis: //Goto the label } else { doThat(); } } doThis: //Label doIt(); I'v...
Toscana asked 5/2, 2011 at 12:12

37

Solved

I've got a nested loop construct like this: for (Type type : types) { for (Type t : types2) { if (some condition) { // Do something and break... break; // Breaks out of the inner loop } } } ...
Orlon asked 20/5, 2009 at 9:7

26

Solved

If I have a for loop which is nested within another, how can I efficiently come out of both loops (inner and outer) in the quickest possible way? I don't want to have to use a boolean and then hav...
Calycine asked 27/11, 2008 at 23:58

3

Solved

I am trying to implement nested for loops using Terraform 0.12's new features in order to loop through AWS IAM users, each of which can have one or more policies attached. The variable used to repr...
Kneepad asked 8/5, 2019 at 18:54

18

Solved

What's the best way to break from nested loops in Javascript? //Write the links to the page. for (var x = 0; x < Args.length; x++) { for (var Heading in Navigation.Headings) { for (var...
Criss asked 8/10, 2008 at 14:47

10

Solved

I've been tasked with helping some accountants solve a common problem they have - given a list of transactions and a total deposit, which transactions are part of the deposit? For example, say I ha...
Idel asked 21/10, 2010 at 16:39

5

Solved

I know it is terribly inefficient and ugly code, but if I have three for loops, nested inside each other such as so: for x in range(0, 10): for y in range(x+1, 11): for z in range(y+1, 11)...
Constantino asked 11/1, 2016 at 15:40

8

Solved

What is the Big-O time complexity of the following nested loops: for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { System.out.println("i = " + i + " j = " ...
Alienage asked 12/12, 2008 at 6:45

7

Solved

I just read this post, and wonder if we can draw the conclusion that a big loop within a small loop must always run faster than a small loop within a big one, no matter what the code does inside th...
Gravois asked 28/5, 2014 at 14:24

1

Solved

This is a continuation question from this answer: https://mcmap.net/q/899232/-using-prophet-package-to-predict-by-group-in-dataframe-in-r I am using the do function in dplyr within the prophet pack...
Osmose asked 20/12, 2021 at 5:0

1

Solved

Given the following nested loop: for (int i = 0; i < 10; i++) { for (var j = 0; j < 10; j++) { print('i: $i, j: $j'); } } If I add a break statement to the inner loop: for (int i = 0; i &...
Tolbutamide asked 10/12, 2021 at 5:25

3

Solved

I have a panel dataset at the country and year level, and I'd like to create a two new variables based on existing ones. year country var1 var2 var3 var 4 mean_var1 relmean_var1 1910 GER 1 ...
Southworth asked 24/11, 2021 at 13:9

7

Solved

How do I get out of nested for or loop in vb.net? I tried using exit for but it jumped or breaked only one for loop only. How can I make it for the following: for each item in itemList for each...
Segmentation asked 15/3, 2011 at 13:17

1

Solved

Let I have a code: for (auto& a : x.as) { for (auto& b : a.bs) { for (auto& c : b.cs) { for (auto& d : c.ds) { if (d.e == ..) { return ... } } } } } as, bs, cs, ds - ...
Fantan asked 16/7, 2021 at 7:59

5

I know it's been asked but I'm having some hard time understanding other programs and nested loops, if someone has a trick to follow nested loops and making a shape with asterisks I would like to k...
Crymotherapy asked 22/11, 2020 at 17:50

3

Solved

I am trying to write a program in Java that captures an integer from the user (assume data is valid) and then outputs a diamond shape depending on the size of the integer, i.e. User enters 5, outpu...
Everglades asked 25/10, 2011 at 10:8

© 2022 - 2024 — McMap. All rights reserved.