Loop structures: Difference between revisions

Better structure
(Better structure)
Line 2:
[[Category:Maintenance]]In this former task, we document loop structures offered by different languages.
 
== ;What are loops?==:
 
Loops are control structures that allow sections of code to be executed repeatedly according to the controlling conditions of the loop.
Line 8:
There are two types of loops:
 
== ;Repetition ==:
 
== Repetition ==
Additionally, there is the overly simple repetitive loop: [[repeat|repetition]]. The simplistic construct executes a block of code, or a procedure, a given number of times, without explicitly exposing any state change to the looped procedure.
 
=== ;Iterative loops ===:
 
An [[:Category:Iteration|iterative loop]] repeatedly executes a set of instructions as the iterator steps through a series of values. Types of iterative loops include [[forloop]]s and [[foreach]] loops. An iterative loop is a repetition but with a variable dependent on the current iteration. This allows the looped procedure to vary slightly between iterations. For example, the same operation can be carried out on each iteration, but each time on a different object.
 
 
=== ;Conditional loops ===:
 
A [[conditional loop]] tests for a condition around the loop, and repeatedly executes a block of [[instruction]]s whilst the [[condition]] is true. Types of [[conditional loop]]s include [[while]] loops and [[until]] loops.
 
 
'''Examples here should be migrated to an appropriate [[:Category:Iteration|Iteration]] page and removed from here. If a page does not exist demonstrating a particular loop structure, discuss it [[:Category talk:Iteration|here]].'''
<br><br>
 
=={{header|AmbientTalk}}==
1,392

edits