For Loop

More useful stuff about loops. This leaves the impression that the middle part of a given loop should be a test, but I’m wondering how a sub-loop happens.

For loop – Wikipedia, the free encyclopedia

Three-expression for loops

This type of for loop is found in nearly all languages which share a common heritage with the C programming language. It is characterized by a three-parameter loop control expression; consisting of an initializer, a loop-test, and a counting expression. A representative example in C is:

for (i = 0; i < 10; i++)
/* loop body */

The three control expressions, separated by semicolons here, are from left to right the initializer expression, the loop test expression, and the counting expression. The initializer is evaluated exactly once right at the beginning. The loop test expression is evaluated at the beginning of each iteration through the loop, and determines when the loop should exit. Finally, the counting expression is evaluated at the end of each loop iteration – even if continue is called – and is usually responsible for altering the loop variable.

In most languages which provide this type of for loop, each of the three control loop expressions is optional. When omitted the loop test expression is taken to always be true, while the initializer and counting expressions are treated as no-ops when omitted. The semicolons in the syntax are sufficient to indicate the omission of one of the expressions.

Conditionals, and Loops

I’ve been busy trying to automate the production of nodes for my Morcego installation, and find myself hung up on how to script an interative process for making similar links.
After much searching and head-scratching, I’ve found something that’s not quite an Aha! moment, but does make sense of something I’ve puzzled over.

Conditional (programming) – Wikipedia, the free encyclopedia

Else If

  • By using Else If, it is possible to combine several conditions.
  • Only the statements following the first condition that is found to be true will be executed.
  • All other statements will be skipped.
  • The statements of the final Else will be executed if none of the conditions are true.