Top "For-loop" questions

A for loop is a control structure used by many programming languages to iterate over a range.

Using a variable in brace expansion range fed to a for loop

Here is myscript.sh #!/bin/bash for i in {1..$1}; do echo $1 $i; done If I run myscript.sh 3 the output …

bash for-loop brace-expansion
Python - `break` out of all loops

I am using multiple nested for loops. In the last loop there is an if statement. When evaluated to True …

python loops python-2.7 for-loop break
Using command line argument range in bash for loop prints brackets containing the arguments

It's probably a lame question. But I am getting 3 arguments from command line [ bash script ]. Then I am trying to …

bash command-line loops for-loop arguments
Creating a Christmas Tree using for loops

I am trying to make a christmas tree using for loops and nested for loops. For me to do that …

java for-loop nested-loops
How do I check for last loop iteration in Django template?

I have a basic question, in the Django template language how can you tell if you are at the last …

django for-loop django-templates
Renaming multiples files with a bash loop

I need to rename 45 files, and I don't want to do it one by one. These are the file names: …

bash for-loop batch-rename
How do I make this loop all children recursively?

I have the following: for (var i = 0; i < children.length; i++){ if(hasClass(children[i], "lbExclude")){ children[i].parentNode.…

javascript recursion loops for-loop children
Scala downwards or decreasing for loop?

In Scala, you often use an iterator to do a for loop in an increasing order like: for(i <…

scala iterator loops for-loop
Why does the order of the loops affect performance when iterating over a 2D array?

Below are two programs that are almost identical except that I switched the i and j variables around. They both …

c performance for-loop optimization cpu-cache
Thoughts on foreach with Enumerable.Range vs traditional for loop

In C# 3.0, I'm liking this style: // Write the numbers 1 thru 7 foreach (int index in Enumerable.Range( 1, 7 )) { Console.WriteLine(index); } over …

c# .net c#-3.0 for-loop