Foreach loop: Difference between revisions

Content deleted Content added
mNo edit summary
No edit summary
 
(45 intermediate revisions by 27 users not shown)
Line 1:
{{Short description|controlControl flow statement for traversing items in a collection}}
{{for|"for all" in logic (∀)|Universal quantification}}
[[File:For-Loop-Mint-Programming-Language-Type-2.gif|thumb|{{mono|foreach}} loops are almost always used to iterate over items in a sequence of elements.]]
{{Loop constructs}}<!-- DO NOT remove. Discuss navigation concept at [[Talk:Do while loop#Helpbox experiment]] -->
 
In [[computer programming]], '''foreach loop''' (or '''for-each loop''') is a [[control flow]] statement for traversing items in a [[Collection class|collection]]. {{mono|foreach}} is usually used in place of a standard {{mono|[[For loop|for]]}} loop [[Statement (computer science)|statement]]. Unlike other {{mono|for}} loop constructs, however, {{mono|foreach}} loops<ref>{{cite web
[[File:For-Loop-Mint-Programming-Language-Type-2.gif|thumb|For each loops are almost always used to iterate over items in a sequence of elements.]]
{{Loop constructs}}<!-- NOTE: Please don't remove. Discuss navigation concept at [[Talk:Do_while_loop#Helpbox_experiment] -->
 
'''Foreach loop''' (or '''for each loop''') is a [[control flow]] statement for traversing items in a [[Collection class|collection]]. Foreach is usually used in place of a standard '''[[for loop]]''' [[statement (programming)|statement]]. Unlike other for loop constructs, however, foreach loops<ref>{{cite web
| url=http://www.digitalmars.com/d/statement.html#ForeachStatement
| title=D Programming Language <ttcode>foreach</ttcode> Statement Documentation
| access-date=2008-08-04
| publisher=Digital Mars
}}</ref> usually maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this ''{{mono|x''}} times". This avoids potential [[off-by-one error]]s and makes code simpler to read. In [[object-oriented]] languages, an [[iterator]], even if implicit, is often used as the means of traversal.
 
The ''{{mono|foreach''}} statement in some languages has some defined order, processing each item in the collection from the first to the last.
The ''{{mono|foreach''}} statement in many other languages, especially [[array programming]] languages, does not have any particular order. This simplifies [[loop optimization]] in general and in particular allows [[vector processing]] of items in the collection concurrently.
 
== Syntax ==
Syntax varies among languages. Most use the simple word <code>for</code>, although other use the more logical word <code>foreach</code>, roughly as follows:
 
forforeach(key, each itemvalue) in collection: {
do# Do something to itemvalue #
}
 
== Language support ==
[[Programming language]]s which support foreach loops include [[ABC (programming language)|ABC]], [[ActionScript]], [[Ada (programming language)|Ada]], [[C++]] (since [[C++11]]), [[C Sharp (programming language)|C#]], [[ColdFusion Markup Language]] (CFML), [[Cobra (programming language)|Cobra]], [[D (programming language)|D]], [[Daplex]] (query language), [[Delphi (software)|Delphi]], [[ECMAScript]], [[Erlang (programming language)|Erlang]], [[Java (programming language)|Java]] (since 1.5), [[JavaScript]], [[Lua (programming language)|Lua]], [[Objective-C]] (since 2.0), [[ParaSail (programming language)|ParaSail]], [[Perl]], [[PHP]], [[Prolog]],<ref>{{Cite web |url=https://www.swi-prolog.org/pldoc/man?predicate=foreach/2 |title=SWI-Prolog – foreach/2 |website=Swi-prolog.org |access-date=2020-02-10}}</ref> [[Python (programming language)|Python]], [[R (programming language)|R]], [[REALbasic]], [[Rebol]],<ref>{{Cite web |url=http://www.rebol.com/ |title=Rebol}}</ref> [[Red (programming language)|Red]],<ref>{{Cite web |url=https://www.red-lang.org/ |title=Red Programming Language}}</ref> [[Ruby (programming language)|Ruby]], [[Scala (programming language)|Scala]], [[Smalltalk]], [[Swift (programming language)|Swift]], [[Tcl]], [[tcsh]], [[Unix shell]]s, [[Visual Basic (.NET)]], and [[Windows PowerShell]]. Notable languages without foreach are [[C (programming language)|C]], and C++ pre-C++11.
 
[[Programming language]]s which support foreach loops include [[ABC (programming language)|ABC]], [[ActionScript]], [[Ada (programming language)|Ada]], [[C++11]], [[C Sharp (programming language)|C#]], [[ColdFusion Markup Language]] (CFML), [[Cobra (programming language)|Cobra]], [[D (programming language)|D]], [[Daplex]] (query language), [[Delphi (software)|Delphi]], [[ECMAScript]], [[Erlang (programming language)|Erlang]], [[Java (programming language)|Java]] (since 1.5), [[JavaScript]], [[Lua (programming language)|Lua]], [[Objective-C]] (since 2.0), [[ParaSail (programming language)|ParaSail]], [[Perl]], [[PHP]], [[Prolog]],<ref>{{Cite web|url=https://www.swi-prolog.org/pldoc/man?predicate=foreach/2|title=SWI-Prolog -- foreach/2|website=www.swi-prolog.org|access-date=2020-02-10}}</ref> [[Python (programming language)|Python]], [[REALbasic]], [[Ruby (programming language)|Ruby]], [[Scala (programming language)|Scala]], [[Smalltalk]], [[Swift (programming language)|Swift]], [[Tcl]], [[tcsh]], [[Unix shell]]s, [[Visual Basic .NET]], and [[Windows PowerShell]]. Notable languages without foreach are [[C (programming language)|C]], and [[C++]] pre-C++11.
 
=== ActionScript 3.0 ===
 
[[ActionScript]] supports the ECMAScript 4.0 Standard<ref>{{cite web|url=https://www.ecma-international.org/activities/Languages/Language%20overview.pdf |title=Proposed ECMAScript 4th Edition – Language Overview |access-date=2020-02-21}}</ref> for <code>for each .. in</code><ref>{{cite web|url=https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/statements.html#for_each..in |title=for each..in |access-date=2020-02-21}}</ref> which pulls the value at each index.
 
Line 53 ⟶ 52:
=== Ada ===
{{Wikibooks|Ada Programming|Control}}
 
[[Ada (programming language)|Ada]] supports foreach loops as part of the normal [[for loop]]. Say X is an [[Array data structure|array]]:
 
Line 124 ⟶ 122:
 
Most general: string or array as collection (collection size known at run-time)
: ''Note: {{code|idxtype}} can be removed and <code>[[typeof]](col[0])</code> used in its place with [[GNU Compiler Collection|GCC]]''
<syntaxhighlight lang="c" highlight="5-8" line>
#include <stdio.h>
Line 174 ⟶ 172:
 
=== C++ ===
 
[[C++11]] provides a foreach loop. The syntax is similar to that of [[Foreach loop#Java|Java]]:
 
Line 193 ⟶ 190:
C++11 range-based for statements have been implemented in [[GNU Compiler Collection]] (GCC) (since version 4.6), [[Clang]] (since version 3.0) and [[Visual C++]] 2012 (version 11 <ref>{{cite web|url=http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx |title=C++11 Features in Visual C++ 11 - Visual C++ Team Blog - Site Home - MSDN Blogs |publisher=Blogs.msdn.com |date=2011-09-12 |access-date=2013-08-04}}</ref>)
 
The range-based <ttcode>for</ttcode> is [[syntactic sugar]] equivalent to:
 
<syntaxhighlight lang="Cpp">
Line 203 ⟶ 200:
</syntaxhighlight>
 
The compiler uses [[argument-dependent lookup]] to resolve the <ttcode>begin</ttcode> and <ttcode>end</ttcode> functions.<ref>{{cite web|url=https://en.cppreference.com/w/cpp/language/range-for |title=Range-based for loop (since C++11) |publisher=en.cppreference.com |access-date=2018-12-03}}</ref>
 
The [[C++ Standard Library]] also supports <ttcode>for_each</ttcode>,<ref>{{cite web|url=http://en.cppreference.com/w/cpp/algorithm/for_each |title=std::for_each - cppreference |publisher=en.cppreference.com |access-date=2017-09-30}}</ref> that applies each element to a function, which can be any predefined function or a lambda expression. While range-based for is only from the beginningstart to the end, the range andor direction you can changebe the direction or rangechanged by altering the first two parameters.
 
<syntaxhighlight lang="Cpp">
Line 216 ⟶ 213:
std::vector<int> v {1, 2, 3, 4, 5};
 
std::for_each(v.begin(), v.end(), [&](int i)
{
std::cout << i << '\n';
Line 223 ⟶ 220:
std::cout << "reversed but skip 2 elements:\n";
 
std::for_each(v.rbegin()+2, v.rend(), [&](int i)
{
std::cout << i << '\n';
Line 266 ⟶ 263:
 
=== C++/CLI ===
 
The [[C++/CLI]] language proposes a construct similar to C#.
 
Line 272 ⟶ 268:
<!-- At the time of writing, there is no documented C++/CLI support in the [[mw:Extension:SyntaxHighlight GeSHi|MediaWiki syntax highliter]] -->
<syntaxhighlight lang="c#">
for each (int x in myArray)
{
{
Console::WriteLine(x);
}
}
</syntaxhighlight>
 
Line 282 ⟶ 278:
 
==== Script syntax ====
 
<syntaxhighlight lang="cfs">
// arrays
Line 322 ⟶ 317:
 
==== Tag syntax ====
 
<syntaxhighlight lang="CFM">
<!--- arrays --->
Line 339 ⟶ 333:
 
=== Common Lisp ===
 
[[Common Lisp]] provides foreach ability either with the ''dolist'' macro:
<syntaxhighlight lang="LISP">
Line 358 ⟶ 351:
=== D ===
{{Main|D (programming language)}}
 
<syntaxhighlight lang="D">
foreach(item; set) {
// do something to item
}
</syntaxhighlight>
 
or
 
<syntaxhighlight lang="D">
foreach(argument) {
// pass value
Line 371 ⟶ 367:
=== Dart ===
{{Main|Dart (programming language)}}
 
<syntaxhighlight lang="Java">
for (final element in someCollection) {
Line 379 ⟶ 374:
 
=== Object Pascal, Delphi ===
{{Main|Object Pascal|Delphi (software)}}
Foreach support was added in [[Delphi (software)|Delphi]] 2005, and uses an enumerator variable that must be declared in the ''var'' section.
 
Foreach support was added in [[Delphi (programming language)|Delphi]] 2005, and uses an enumerator variable that must be declared in the ''var'' section.
 
<syntaxhighlight lang="Delphi">
Line 391 ⟶ 385:
 
=== Eiffel ===
 
The iteration (foreach) form of the [[Eiffel (programming language)|Eiffel]] loop construct is introduced by the keyword <code lang=Eiffel>across</code>.
 
Line 417 ⟶ 410:
 
=== Go ===
 
[[Go (programming language)|Go]]'s foreach loop can be used to loop over an array, slice, string, map, or channel.
 
Using the two-value form, we getgets the index/key (first element) and the value (second element):
<syntaxhighlight lang="go">
for index, value := range someCollection {
Line 427 ⟶ 419:
</syntaxhighlight>
 
Using the one-value form, we getgets the index/key (first element):
<syntaxhighlight lang="go">
for index := range someCollection {
Line 435 ⟶ 427:
 
=== Groovy ===
 
[[Groovy (programming language)|Groovy]] supports ''for'' loops over collections like arrays, lists and ranges:
 
Line 466 ⟶ 457:
 
Collections in Groovy can also be iterated over using the ''each'' keyword
and a closure. By default, the loop dummy is named ''it''
 
<syntaxhighlight lang="Groovy">
Line 474 ⟶ 465:
 
=== Haskell ===
[[Haskell]] allows looping over lists with [[Monad (functional programming)|monadic]] actions using <code>mapM_</code> and <code>forM_</code> (<code>mapM_</code> with its arguments flipped) from [http://hackage.haskell.org/package/base-4.6.0.1/docs/Control-Monad.html Control.Monad]:
 
[[Haskell (programming language)|Haskell]] allows looping over lists with [[Monad (functional programming)|monadic]] actions using <code>mapM_</code> and <code>forM_</code> (<code>mapM_</code> with its arguments flipped) from [http://hackage.haskell.org/package/base-4.6.0.1/docs/Control-Monad.html Control.Monad]:
 
{| class="wikitable"
Line 513 ⟶ 503:
 
=== Java ===
 
In [[Java (programming language)|Java]], a foreach-construct was introduced in [[Java Development Kit]] (JDK) 1.5.0.<ref name="jdk5release">
"Enhanced for Loop - This new language construct[...]"
Line 540 ⟶ 529:
|year=2004
|publisher=[[Sun Microsystems, Inc.]]
}}</ref><ref name=Bloch>{{cite book | title= "Effective Java: Programming Language Guide" |last=Bloch| first=Joshua| publisher=Addison-Wesley | edition=third | isbn=978-0134685991| year=2018}}</ref>{{rp|264}}
}}</ref>
 
<syntaxhighlight lang="Java">
Line 546 ⟶ 535:
// Do something to item
}
</syntaxhighlight>
 
Java also provides the stream api since java 8:<ref name=Bloch>{{cite book | title= "Effective Java: Programming Language Guide" |last=Bloch| first=Joshua| publisher=Addison-Wesley | edition=third | isbn=978-0134685991| year=2018}}</ref>{{rp|294-203}}
<syntaxhighlight lang="Java">
List<Integer> intList = List.of(1, 2, 3, 4);
intList.stream().forEach(i -> System.out.println(i));
</syntaxhighlight>
 
=== JavaScript ===
The [[EcmaScriptECMAScript 6]] standard has <code>[https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/for...of for..of]</code> for index-less iteration over generators, arrays and more:
<syntaxhighlight lang="JavaScript">
for (var item of array){
Line 556 ⟶ 551:
</syntaxhighlight>
 
Alternatively, function-based style: <ref>[{{Cite web|url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach]|title=Array.prototype.forEach() - JavaScript &#124; MDN|date=16 December 2023 }}</ref>
 
<syntaxhighlight lang="JavaScript">
Line 572 ⟶ 567:
</syntaxhighlight>
 
To limit the iteration to the object's own properties, excluding those inherited through the prototype chain, it is sometimes useful to add a hasOwnProperty() test, [[Comparison of layout engines (ECMAScript)#Object object|if supported by the JavaScript engine]] (for WebKit/Safari, this means "in version 3 or later").
 
<syntaxhighlight lang="JavaScript">
Line 590 ⟶ 585:
</syntaxhighlight>
 
=== Lua ===
=== Lua<ref>{{Cite web|url=https://en.wikibooks.org/wiki/Lua_Programming/Tables#Foreach_loop|title=Lua Programming/Tables - Wikibooks, open books for an open world|website=en.wikibooks.org|language=en|access-date=2017-12-06}}</ref> ===
{{Main|Lua (programming language)}}
Source:<ref>{{Cite web|url=https://en.wikibooks.org/wiki/Lua_Programming/Tables#Foreach_loop|title=Lua Programming/Tables - Wikibooks, open books for an open world|website=en.wikibooks.org|language=en|access-date=2017-12-06}}</ref>
 
Iterate only through numerical index values:<syntaxhighlight lang="lua">
for index, value in ipairs(array) do
Line 603 ⟶ 600:
 
=== Mathematica ===
 
In [[Mathematica]], <code>Do</code> will simply evaluate an expression for each element of a list, without returning any value.
 
Line 621 ⟶ 617:
=== MATLAB ===
{{Main|MATLAB}}
 
<syntaxhighlight lang="MATLAB">
for item = array
Line 629 ⟶ 624:
 
=== Mint ===
 
For each loops are supported in Mint, possessing the following syntax:
<syntaxhighlight lang="Ruby">
Line 659 ⟶ 653:
 
=== Objective-C ===
 
Foreach loops, called [[Objective-C#Fast enumeration|Fast enumeration]], are supported starting in [[Objective-C]] 2.0. They can be used to iterate over any object that implements the NSFastEnumeration protocol, including NSArray, NSDictionary (iterates over keys), NSSet, etc.
 
Line 665 ⟶ 658:
NSArray *a = [NSArray new]; // Any container class can be substituted
 
for(id obj in a) { // Note the dynamicDynamic typing (weis doused. notThe needtype toof knowobject thestored
// Type of object stored in 'a'. can Inbe fact,unknown. thereThe array can behold many different
// many different types of object in the array.
 
printf("%s\n", [[obj description] UTF8String]); // Must use UTF8String with %s
Line 706 ⟶ 699:
 
=== OCaml ===
[[OCaml]] is a [[functional programming]] language. Thus, the equivalent of a foreach loop can be achieved as a library function over lists and arrays.
 
[[OCaml]] is a [[functional language]]. Thus, the equivalent of a foreach loop can be achieved as a library function over lists and arrays.
 
For lists:
Line 734 ⟶ 726:
 
=== ParaSail ===
 
The [[ParaSail (programming language)|ParaSail]] parallel programming language supports several kinds of iterators, including a general "for each" iterator over a container:
 
Line 756 ⟶ 747:
 
=== Pascal ===
 
In [[Pascal (programming language)|Pascal]], ISO standard 10206:1990 introduced iteration over [[Pascal (programming language)#Set types|set types]], thus:
 
Line 771 ⟶ 761:
 
=== Perl ===
 
In [[Perl]], ''foreach'' (which is equivalent to the shorter for) can be used to traverse elements of a list. The expression which denotes the collection to loop over is evaluated in list-context and each item of the resulting list is, in turn, aliased to the loop variable.
 
Line 815 ⟶ 804:
 
=== PHP ===
{{Main|PHP_syntax_and_semanticsPHP syntax and semantics}}
 
<syntaxhighlight lang="php">
foreach ($set as $value) {
Line 835 ⟶ 823:
<syntaxhighlight lang="php">
$arr = array(1, 2, 3);
foreach ($arr as &$value) { // Note theThe &, $value is a reference to the original value inside $arr
$value++;
}
Line 849 ⟶ 837:
=== Python ===
{{Main|Python (programming language)}}
 
<syntaxhighlight lang="python">
for item in iterable_collection:
Line 875 ⟶ 862:
# Do stuff with item
# Possibly assign it back to seq[i]
</syntaxhighlight>
 
=== R ===
{{Main|R (programming language)}}
<syntaxhighlight lang="R">
for (item in object) {
# Do something with item
}
</syntaxhighlight>
 
As <code>for ... in</code> is the only kind of <code>for</code> loop in R, the equivalent to the "counter" loop found in other languages is...
 
<syntaxhighlight lang="R">
for (i in seq_along(object)) {
# Do something with object[[i]]
}
</syntaxhighlight>
 
Line 892 ⟶ 895:
 
=== Raku ===
 
In [[Raku (programming language)|Raku]], a sister language to Perl, ''for'' must be used to traverse elements of a list (''foreach'' is not allowed). The expression which denotes the collection to loop over is evaluated in list-context, but not flattened by default, and each item of the resulting list is, in turn, aliased to the loop variable(s).
 
Line 966 ⟶ 968:
=== Ruby ===
{{Main|Ruby (programming language)}}
 
<syntaxhighlight lang="Ruby">
set.each do |item|
Line 984 ⟶ 985:
 
<syntaxhighlight lang="Ruby">
set.each do |itemkey,value|
# do something to itemkey
# do something to value
end
Line 992 ⟶ 993:
=== Rust ===
{{Main|Rust (programming language)}}
The <code>for</code> loop has the structure <syntaxhighlight lang="rust" inline>for <pattern> in <expression> { /* optional statements */ }</syntaxhighlight>. It implicitly calls the [https://doc.rust-lang.org/std/iter/trait.IntoIterator.html <code>IntoIterator::into_iter</code>] method on the expression, and uses the resulting value, which must implement the [https://doc.rust-lang.org/std/iter/trait.Iterator.html <code>Iterator</code>] trait. If the expression is itself an iterator, it is used directly by the <code>for</code> loop through an [https://doc.rust-lang.org/std/iter/trait.IntoIterator.html#impl-IntoIterator-25 implementation of <code>IntoIterator</code> for all <code>Iterator</code>s] that returns the iterator unchanged. The loop calls the <code>Iterator::next</code> method on the iterator before executing the loop body. If <code>Iterator::next</code> returns <code>[[option type|Some(_)]]</code>, the value inside is assigned to the [[pattern matching|pattern]] and the loop body is executed; if it returns <code>None</code>, the loop is terminated.
 
The <code>for</code> loop has the structure <code><nowiki>for <pattern> in <expression> { /* optional statements */ }</nowiki></code>. It implicitly calls the [https://doc.rust-lang.org/std/iter/trait.IntoIterator.html <code>IntoIterator::into_iter</code>] method on the expression, and uses the resulting value, which must implement the [https://doc.rust-lang.org/std/iter/trait.Iterator.html <code>Iterator</code>] trait. If the expression is itself an iterator, it is used directly by the <code>for</code> loop through an [https://doc.rust-lang.org/std/iter/trait.IntoIterator.html#impl-IntoIterator-25 implementation of <code>IntoIterator</code> for all <code>Iterator</code>s] that returns the iterator unchanged. The loop calls the <code>Iterator::next</code> method on the iterator before executing the loop body. If <code>Iterator::next</code> returns <code>[[option type|Some(_)]]</code>, the value inside is assigned to the [[pattern matching|pattern]] and the loop body is executed; if it returns <code>None</code>, the loop is terminated.
 
<syntaxhighlight lang="Rust">
Line 1,026:
=== Scala ===
{{Main|Scala (programming language)}}
 
<syntaxhighlight lang="Scala">
// return list of modified elements
Line 1,060 ⟶ 1,059:
 
=== Swift ===
[[Swift (programming language)|Swift]] uses the <code>for</code>…<code>in</code> construct to iterate over members of a collection.<ref>{{Cite web|url=https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_language/ControlFlow.html#//apple_ref/doc/uid/TP40014097-CH9-XID_153|title=Control Flow — the Swift Programming Language (Swift 5.5)}}</ref>
 
[[Swift (programming language)|Swift]] uses the <code>for</code>…<code>in</code> construct to iterate over members of a collection.<ref>https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_language/ControlFlow.html#//apple_ref/doc/uid/TP40014097-CH9-XID_153</ref>
 
<syntaxhighlight lang="objc">
Line 1,084 ⟶ 1,082:
 
=== SystemVerilog ===
 
[[SystemVerilog]] supports iteration over any vector or array type of any dimensionality using the <code>foreach</code> keyword.
 
Line 1,127 ⟶ 1,124:
 
=== Tcl ===
 
[[Tcl]] uses foreach to iterate over lists. It is possible to specify more than one iterator variable, in which case they are assigned sequential values from the list.
{| class="wikitable"
Line 1,160 ⟶ 1,156:
|}
 
=== Visual Basic (.NET) ===
{{Main|Visual Basic (.NET)}}
<syntaxhighlight lang="VBNet">
For Each item In enumerable
Line 1,168 ⟶ 1,164:
</syntaxhighlight>
 
or without [[type inference]]
 
<syntaxhighlight lang="VBNet">
Line 1,202 ⟶ 1,198:
</syntaxhighlight>
 
=== Extensible Stylesheet Language (XSLT) ===
{{Main|XSLT}}
<syntaxhighlight lang="xml">
Line 1,219 ⟶ 1,215:
{{Reflist|2}}
 
[[Category:Control flow]]
[[Category:Iteration in programming]]
[[Category:Programming language comparisons]]
<!-- Hidden categories below -->
[[Category:Articles with example Ada code]]
[[Category:Articles with example C code]]
[[Category:Articles with example C++ code]]
[[Category:Articles with example C Sharp code]]
[[Category:Articles with example D code]]
[[Category:Articles with example Eiffel code]]
[[Category:Articles with example Haskell code]]
[[Category:Articles with example Java code]]
[[Category:Articles with example JavaScript code]]
[[Category:Articles with example Lisp (programming language) code]]
[[Category:Articles with example MATLAB/Octave code]]
[[Category:Articles with example Objective-C code]]
[[Category:Articles with example OCaml code]]
[[Category:Articles with example Pascal code]]
[[Category:Articles with example Perl code]]
[[Category:Articles with example PHP code]]
[[Category:Articles with example Python (programming language) code]]
[[Category:Articles with example R code]]
[[Category:Articles with example Racket code]]
[[Category:Articles with example Ruby code]]
[[Category:Articles with example Rust code]]
[[Category:Articles with example Scala code]]
[[Category:Articles with example Scheme (programming language) code]]
[[Category:Articles with example Smalltalk code]]
[[Category:Articles with example Swift code]]
[[Category:Articles with example Tcl code]]
[[Category:Control flow]]
[[Category:Programming language comparisons]]
[[Category:Articles with example Java code]]
[[Category:Articles with example Haskell code]]
 
[[ru:Цикл просмотра]]