Difference between revisions of "Loop (computing)"
From Wiki @ Karl Jones dot com
Karl Jones (Talk | contribs) (Created page with "In computing, a '''loop''' is a sequence of statements which is specified once but which may be carried out several times in successio...") |
Karl Jones (Talk | contribs) (→Examples) |
||
Line 11: | Line 11: | ||
== Examples == | == Examples == | ||
− | + | Various types of loop exist: | |
+ | |||
+ | * Count-controlled loops | ||
+ | * Condition-controlled loops | ||
+ | * Collection-controlled loops | ||
+ | * General iteration | ||
+ | * Infinite loops | ||
+ | * Continuation with next iteration | ||
+ | * Redo current iteration | ||
+ | * Restart loop | ||
+ | * Early exit from loops | ||
+ | * Loop variants and invariants | ||
== See also == | == See also == |
Revision as of 08:07, 9 September 2015
In computing, a loop is a sequence of statements which is specified once but which may be carried out several times in succession.
(TO DO: expand, organize, cross-reference, illustrate.)
Description
The code "inside" the loop (the body of the loop, shown below as xxx) is obeyed a specified number of times, or once for each of a collection of items, or until some condition is met, or indefinitely.
In functional programming languages, such as Haskell and Scheme, loops can be expressed by using recursion or fixed point iteration rather than explicit looping constructs. Tail recursion is a special case of recursion which can be easily transformed to iteration.
Examples
Various types of loop exist:
- Count-controlled loops
- Condition-controlled loops
- Collection-controlled loops
- General iteration
- Infinite loops
- Continuation with next iteration
- Redo current iteration
- Restart loop
- Early exit from loops
- Loop variants and invariants
See also
External links
- Control flow: Loops @ Wikipedia