Iteration


 
 

:This article discusses a concept which is exploited in computer programming (but which originated before it). For use in the Japanese and Chinese languages see iteration mark.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Iteration is the repetition of a process, typically within a computer program. It can be used both as a general term, synonymous with repetition, and to describe a specific form of repetition with a mutable state.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

When used in the first sense, recursion is an example of iteration, but typically using a recursive notation, which is typically not the case for iteration.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

However, when used in the second (more restricted) sense, iteration describes the style of programming used in imperative programming languages. This contrasts with recursion, which has a more declarative approach.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Here an example of iteration, in imperative pseudocode:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

var i, a := 0 // initialize a before iteration

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

for i from 1 to 3 { // loop three times

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

a := a + i // increment a by the current value of i

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

}

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

print a // the number 6 is printed

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

In this program fragment, the value of the variable i changes over time, taking the values 1, 2 and 3. This changing value—or mutable state—is characteristic of iteration.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Iteration can be done in functional programming languages. The following example is in Scheme:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

(define (sum n)

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

(define (iter i result)

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

(if (

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

(+ i (iter (+ i 1) result))

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

result))

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

(iter 0 0))

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

An iterator is an object that wraps iteration.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~


 

Computer programming: Computer programming (often simply programming) is the craft of implementing one or more interrelated abstract algorithms using a particular programming language to produce a concrete computer program. Programming has elements of art, science, mathematics, and engineering....

Iteration mark: Iteration marks (Jp. ??? odoriji "dancing mark" , ??? kasaneji, ?????? kurikaeshikig?, or ???? hanpukukig?, "repetition symbols") are used in Japanese to represent a duplicated character. For example, hitobito, "people" is usually written ??, using the kanji for ? with a repetition mark, ?, rather ...

Process: Process (lat. processus - movement) is a naturally occurring or designed sequence of operations or events, possibly taking up time, space, expertise or other resource, which produces some outcome. A process may be identified by the changes it creates in the properties of one or more objects under it...

~ Table of Content ~

Introduction
See also
 


 

~ Related Subjects ~

Computer program (2) - Space (1) - Expertise (1) - Resource (1) - Event (1) - Time (1) - Operation (1) - Process management (1) - Process theory (1) - :Category:Nature (1) - Properties (1) - Object (1) - Project (1) - Jp. (1) - Mutable (1) -
 

~ Community ~

History Forum
Come and discuss about History, Civilizations, Historical Events and Figures
History Web-Ring
A community of sites, blogs and forums dedicated to History. Do not hesitate to submit your site.