Definition of

Iteration

Repetition

The idea of ​​iteration refers to a repetition or reiteration.

Iteration is a word that has its origin in the Latin term iteratio . It is a word that describes the act and consequence of iterate , a verb that is used as a synonym for reiterate or repeat (understood as developing an action again or pronouncing again what had already been said).

The concept is usually used to give a name to the act of repeating certain steps several times . In the field of mathematics , an iterated function is one that is composed of itself. A composite function, on the other hand, is achieved from the successive application of other functions . This means that the iteration of a function constitutes the creation of a composite function from the repetition of the function itself.

Iterated functions are studied in the field of dynamic systems (those complex systems that present alterations in their state according to limits, elements and relationships ) and fractals (semigeometric objects whose structure is repeated at different scales).

Mathematics also talks about iterative methods that are useful for solving problems through successive approximations to the solution, starting from an initial estimate. These types of strategies can be more useful than direct methods for solving problems with thousands or millions of variables.

Iteration in programming

For programming , on the other hand, iteration consists of reiterating a set of instructions or actions with one or more objectives. To cite an example, many web pages are prepared to adapt to changes in their structure, such as aesthetic alterations or the number of accessible sections, whose links are displayed in the form of tabs; In the latter case, if an iteration is used to place one by one and a verification is requested, developers can activate and deactivate each element according to their needs, without causing an error at load time.

Going deeper into the previous case, it is possible to use a loop (structure designed to establish an iteration) and indicate the number of the first tab, as well as the last, so that it can go through them one by one. Within it, the sample of elements should be conditioned , asking if they are available; If so, its position would be calculated, which (in this page model) will always be relative. On the contrary, if said section had been deactivated, the next one would be checked, provided that the maximum limit had not been reached.

The example presented above describes the use of an iteration to dynamically arrange tabs on a page, whenever they are active or available; In each lap, a control is carried out, which, if positive, opens the doors to a series of simple actions . But the possibilities are endless, given that programming offers tools that each developer uses by applying their own ingenuity, imagination and knowledge, being able to modify them, combine them and even create new ones.

Computing

The notion of iteration is used in programming.

Loop and control structure

It is worth mentioning that in computing an iteration is associated with the terms loop and control structure , which refer to the reserved words while and for , among others. Basically, a condition is usually established that must be met for the lines of code within said loops to be executed.

However, in many cases it is necessary to perform these actions at least once before checking, for which a different model is used, contemplated in some languages ​​with structures such as do while . In short, and completing the example of the sections, if the developers are sure that at least one tab should always be displayed, they have the possibility of calculating its position and then proceeding to check (through iteration) if there are others available .