Site banner
.
Home Forums Blogs Articles Photos Videos Contact FAQ                    
.
.
Wisdom Archive
Body Mind and Soul
Faith and Belief
God and Religion
Law of Attraction
Life and Beyond
Love and Happiness
Peace of Mind
Peace on Earth
Personal Faith
Spiritual Festivals
Spiritual Growth
Spiritual Guidance
Spiritual Inspiration
Spirituality and Science
Spiritual Retreats
More Wisdom
Buddhism Archives
Hinduism Archives
Sustainability
Theology Archives
Even more Wisdom
2012 - Year 2012
Affirmations
Aura
Ayurveda
Chakras
Consciousness
Cultural Creatives
Diksha (Deeksha)
Dream Dictionary
Dream Interpretation
Dream interpreter
Dreams
Enlightenment
Essential Oils
Feng Shui
Flower Essences
Gaia Hypothesis
Indigo Children
Kalki Bhagavan
Karma
Kundalini
Kundalini Yoga
Life after death
Mayan Calendar
Meaning of Dreams
Meditation
Morphogenetic Fields
Psychic Ability
Reincarnation
Spiritual Art, Music & Dance
Spiritual Awakening
Spiritual Enlightenment
Spiritual Healing
Spirituality and Health
Spiritual Jokes
Spiritual Parenting
Vastu Shastra
Womens Spirituality
Yoga Positions
Site map 2
Site map


Dream Sharing Forum

at Global Oneness Community.

Share your dreams and let others help you with the interpretation!
Dream Sharing Forum



.

Control flow - Loops

Control flow - Loops: Encyclopedia II - Control flow - Loops

A loop is a sequence of statements which is specified once but which may be carried out several times in succession. 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. In some languages, such as Scheme, loops are often expressed using tail recursion rather than explicit looping constructs. Control ...

See also:

Control flow, Control flow - Primitives, Control flow - Labels, Control flow - Goto, Control flow - Subroutines, Control flow - Minimal structured control flow, Control flow - Control structures in practice, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Arithmetic IF, Control flow - Loops, Control flow - Count-controlled loops, Control flow - Condition-controlled loops, Control flow - Collection-controlled loops, Control flow - General iteration, Control flow - Infinite loops, Control flow - Early exit from loops, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Conditions in PL/I, Control flow - Exceptions in C++ and derived languages, Control flow - Proposed control structures, Control flow - Loop with test in the middle, Control flow - Multiple early exit/exit from nested loops, Control flow - Anecdotal evidence

Control flow, Control flow - Anecdotal evidence, Control flow - Arithmetic IF, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Collection-controlled loops, Control flow - Condition-controlled loops, Control flow - Conditions in PL/I, Control flow - Control structures in practice, Control flow - Count-controlled loops, Control flow - Early exit from loops, Control flow - Exceptions in C++ and derived languages, Control flow - General iteration, Control flow - Goto, Control flow - Infinite loops, Control flow - Labels, Control flow - Loop with test in the middle, Control flow - Loops, Control flow - Minimal structured control flow, Control flow - Multiple early exit/exit from nested loops, Control flow - Primitives, Control flow - Proposed control structures, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Subroutines, Goto, Subroutine, Main loop, Recursion, Spaghetti code, Structured programming, Functional programming

Control flow: Encyclopedia II - Control flow - Loops



Control flow - Loops

A loop is a sequence of statements which is specified once but which may be carried out several times in succession. 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.

In some languages, such as Scheme, loops are often expressed using tail recursion rather than explicit looping constructs.

Control flow - Count-controlled loops

Most programming languages have constructions for repeating a loop a certain number of times. Note that if N is less than 1 in these examples then the body is skipped completely. In most cases counting can go downwards instead of upwards and step sizes other than 1 can be used.

   FOR I = 1 TO N            for I := 1 to N do begin
       xxx                       xxx
   NEXT I                    end;

   DO I = 1,N                for ( I=1; I<=N; ++I ) {
       xxx                       xxx
   END DO                    }

See also For loop, Loop counter.

In many programming languages, only integers can be reliably used in a count-controlled loop. Floating-point numbers are represented imprecisely due to hardware constraints, so a loop such as

   for X := 0.1 step 0.1 to 1.0 do

might be repeated 9 or 10 times, depending on rounding errors and/or the hardware and/or the compiler version.

Control flow - Condition-controlled loops

Again, most programming languages have constructions for repeating a loop until some condition changes. Note that some variations place the test at the start of the loop, while others have the test at the end of the loop. In the former case the body may be skipped completely, while in the latter case the body is always obeyed at least once.

   DO WHILE (test)           repeat 
       xxx                       xxx 
   END DO                    until test;

   while (test) {            do
       xxx                       xxx
   }                         while (test);

See also While loop.

Control flow - Collection-controlled loops

A few programming languages (e.g. Smalltalk, Perl, C#) have special constructs which allow you to implicitly loop through all elements of an array, or all members of a set or collection.

   someCollection do: [ :eachElement | xxx ].

   foreach someArray { xxx }

   foreach (string s in myStringCollection) { xxx }

Control flow - General iteration

General iteration constructs such as C's for statement and Common Lisp's do form can be used to express any of the above sorts of loops, as well as others -- such as looping over a number of collections in parallel. Where a more specific looping construct can be used, it is usually preferred over the general iteration construct, since it often makes the purpose of the expression more clear.

Control flow - Infinite loops

Sometimes it is desirable for a program to loop forever, or until an exceptional condition such as an error arises. For instance, an event-driven program may be intended to loop forever handling events as they occur, only stopping when the process is killed by the operator.

More often, an infinite loop is due to a programming error in a condition-controlled loop, wherein the loop condition is never changed within the loop.

Control flow - Early exit from loops

When using a count-controlled loop to search through a table, you may wish to stop searching as soon as you have found the required item. Some programming languages provide a statement such as break or exit, whose effect is to terminate the current loop immediately and transfer control to the statement immediately following that loop. Things can get a bit messy if you are searching a multi-dimensional table using nested loops (see Missing Control Structures below).

Other related archives

Ada, Algol 60, Algol 68, AppleScript, BASIC, C, C programming language, C#, C++, COBOL, Common Lisp, Compilers, D, Dahl, Datamation, Donald Knuth, Duff's device, Edsger Dijkstra, Exceptions, For loop, Fortran, Fortran 77, Functional programming, Goto, IBM 704, INTERCAL programming language, Infinite loops, Java, Loop counter, Main loop, Modula-2, Objective C, PHP, PL/1, Pascal, Perl, Python, Quicksort, Recursion, Ruby, Scheme, Self-modifying code, Smalltalk, Spaghetti code, Structured programming, Subroutine, While loop, assembly language, caches, computer programming, computer science, conditions, continuations, goto, identifier, inline, jump table, loop unwinding, machine-, pipelines, program, programming languages, pseudocode, recursion, scripting programming language, spaghetti code, subroutines, tail recursion, trichotomy



Adapted from the Wikipedia article "Loops", under the G.N U Free Docmentation License. Please also see http://en.wikipedia.org/wiki

More material related to Control Flow can be found here:
Main Page
for
Control Flow
Index of Articles
related to
Control Flow


« Back








Search the Global Oneness web site
Global Oneness is a huge, really huge, web site. Almost whatever you are searching for within health, spirituality, personal development and inspirationals - you will find it here!
Google
 
 

Rate this article!

Please rate this article with 10 as very good and 1 as very poor.

.








Sneak-Peek of Global Oneness Community

Hi friend! The Global Oneness Community, the place for information and sharing about Oneness is not really launched yet (you will see there is still some clean up to do) ...but it is now open for a sneak-peek! And if you wish - please register and become one of the very first members to do so! Jonas

Forum Home, Articles, Photo Gallery, Videos, News, Sitemap
...and much more!


Dream Sharing Forum

at Global Oneness Community.

Share your dreams and let others help you with the interpretation!
Dream Sharing Forum



Forum
Articles
Images Pictures
Videos
News
Sitemap




 

 

 

 

 


 








  » Home » » Home »