Loop structures: Difference between revisions

Content added Content deleted
m (→‎{{header|Déjà Vu}}: Updates example)
(→‎What are loops?: +> repetition)
Line 7: Line 7:


There are two types of loops:
There are two types of loops:


== 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 ===
=== 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 [[: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 ===
=== Conditional loops ===