请输入您要查询的百科知识:

 

词条 Foreach loop
释义

  1. Syntax

  2. Language support

      Ada    C    C#    C++    C++/CLI    ColdFusion Markup Language (CFML)    Script syntax    Tag syntax    Common Lisp    D    Dart    Object Pascal, Delphi    Eiffel    Go    Groovy    Haskell    Haxe    Java    JavaScript    Lua[15]    Mathematica    MATLAB    Mint    Objective-C    OCaml    ParaSail    Pascal    Perl    Perl 6    PHP    Python    Racket    Ruby    Scala    Scheme    Smalltalk    Swift    SystemVerilog    Tcl    Visual Basic .NET    Windows    Conventional command processor    Windows PowerShell    Extensible Stylesheet Language (XSL)  

  3. See also

  4. References

{{Loop constructs}}

For each (or foreach, sometimes called an iterative for-loop) is a control flow statement for traversing items in a collection. Foreach is usually used in place of a standard for statement. Unlike other for loop constructs, however, foreach loops[1] usually maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this x times". This avoids potential off-by-one errors and makes code simpler to read. In object-oriented languages an iterator, even if implicit, is often used as the means of traversal.

The foreach statement in some languages has some defined order, processing each item in the collection from the first to the last.

The 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 for, roughly as follows:

 for each item in collection:   do something to item

Language support

Programming languages which support foreach loops include ABC, ActionScript, Ada, C++11, C#, ColdFusion Markup Language (CFML), Cobra, D, Daplex (query language), ECMAScript, Erlang, Java (since 1.5, using the reserved word for for the for loop and the foreach loop), JavaScript, Lua, Objective-C (since 2.0), ParaSail, Perl, PHP, Python, REALbasic, Ruby, Scala, Smalltalk, Swift, Tcl, tcsh, Unix shells, Visual Basic .NET, and Windows PowerShell. Notable languages without foreach are C, and C++ pre-C++11.

Ada

{{Wikibooks|Ada Programming|Control}}

Ada supports foreach loops as part of the normal for loop. Say X is an array:

for I in X'Range loop

end loop;

This syntax is used on mostly arrays, but will also work with other types when a full iteration is needed.

Ada 2012 has generalized loops to foreach loops on any kind of container (array, lists, maps...):

for Obj of X loop

end loop;

C

The language C does not have collections or a foreach construct. However, it has several standard data structures that can be used as collections, and foreach can be made easily with a macro.

However, two obvious problems occur:

  • The macro is unhygienic: it declares a new variable in the existing scope which remains after the loop.
  • One foreach macro cannot be defined that works with different collection types (e.g., array and linked list) or that is extensible to user types.

C string as a collection of char

  1. include
  2. include

/* foreach macro for using a string as a collection of char */

  1. define foreach( ptrvar, strvar ) char* ptrvar; for( ptrvar=strvar ; (*ptrvar) != '\\0' ; *ptrvar++)

int main(int argc,char* argv[]){

 char* s1 = "abcdefg"; char* s2 = "123456789"; foreach (p1, s1) {  printf("loop 1 %c\",*p1); } foreach (p2, s2){  printf("loop 2 %c\",*p2); } exit(0); return(0);

}

C int array as a collection of int (array size known at compile-time)

  1. include
  2. include

int main(int argc, char* argv[]){

/* foreach macro viewing an array of int values as a collection of int values */

  1. define foreach( intpvar, intary ) int* intpvar; for( intpvar=intary; intpvar < (intary + (sizeof(intary)/sizeof(intary[0]))) ; intpvar++)
     int a1[] = { 1, 1, 2, 3, 5, 8 }; int a2[] = { 3, 1, 4, 1, 5, 9 }; foreach (p1, a1) {  printf("loop 1 %d\", *p1); } foreach (p2, a2){  printf("loop 2 %d\", *p2); } exit(0); return(0);

}

Most general: string or array as collection (collection size known at run-time)

Note: idxtype can be removed and typeof(col[0]) used in its place with GCC

  1. include
  2. include
  3. include

int main(int argc, char* argv[]){

  1. define foreach(idxtype, idxpvar, col, colsiz ) idxtype* idxpvar; for( idxpvar=col ; idxpvar < (col + (colsiz)) ; idxpvar++)
  2. define arraylen( ary ) ( sizeof(ary)/sizeof(ary[0]) )
     char* c1 = "collection"; int c2[] = { 3, 1, 4, 1, 5, 9 }; double* c3; int c3len = 4; c3 = (double*)calloc(c3len, sizeof(double));  c3[0] = 1.2; c3[1] = 3.4; c3[2] = 5.6; c3[3] = 7.8;
 foreach (char, p1, c1, strlen(c1) ) {  printf("loop 1 : %c\",*p1); } foreach (int, p2, c2, arraylen(c2) ){  printf("loop 2 : %d\",*p2); } foreach (double, p3, c3, c3len ){  printf("loop 3 : %3.1lf\",*p3); } exit(0); return(0);

}

C#

In C#, assuming that myArray is an array of integers:

foreach (int x in myArray) { Console.WriteLine(x); }

Language Integrated Query (LINQ) provides the following syntax, accepting a delegate or lambda expression:

myArray.ToList().ForEach(x => Console.WriteLine(x));

C++

C++11 provides a foreach loop. The syntax is similar to that of Java:

  1. include

int main()

{
  for (int i : myint)  {    std::cout << i << '\';  }

}

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 [2])

The range-based for is syntactic sugar equivalent to:

  for (auto __anon = begin(myint); __anon != end(myint); ++__anon)  {    auto i = *__anon;    std::cout << i << '\';  }

The compiler uses argument-dependent lookup to resolve the begin and end functions.[3]

The C++ Standard Library also supports for_each,[4] 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 beginning to the end, the range and direction you can change the direction or range by altering the first two parameters.

  1. include
  2. include // contains std::for_each
  3. include

int main()

{
  std::for_each(v.begin(), v.end(), [&](int i)  {    std::cout << i << '\';  });
  std::for_each(v.rbegin()+2, v.rend(), [&](int i)  {    std::cout << i << '\';  });

}

Qt, a C++ framework, offers a macro providing foreach loops[5] using the STL iterator interface:

  1. include
  2. include

int main()

{
  foreach (int i, list)  {    qDebug() << i;  }

}

Boost, a set of free peer-reviewed portable C++ libraries also provides foreach loops:[6]
  1. include
  2. include

int main()

{
  int myint[] = {1, 2, 3, 4, 5};   BOOST_FOREACH(int &i, myint)  {    std::cout << i << '\';  }

}

C++/CLI

The C++/CLI language proposes a construct similar to C#.

Assuming that myArray is an array of integers:

    for each (int x in myArray)    {        Console::WriteLine(x);    }

ColdFusion Markup Language (CFML)

{{Main|ColdFusion Markup Language}}

Script syntax

// arrays

arrayeach([1,2,3,4,5], function(v){

});

// or

for (v in [1,2,3,4,5]){

}

// or

// (Railo only; not supported in ColdFusion)

letters = ["a","b","c","d","e"];

letters.each(function(v){

});

// structs

for (k in collection){

}

// or

structEach(collection, function(k,v){

});

// or

// (Railo only; not supported in ColdFusion)

collection.each(function(k,v){

});

Tag syntax

#v#

CFML incorrectly identifies the value as "index" in this construct; the index variable does receive the actual value of the array element, not its index.

#collection[k]#

Common Lisp

Common Lisp provides foreach ability either with the dolist macro:

(dolist (i '(1 3 5 6 8 10 14 17))

or the powerful loop macro to iterate on more data types

(loop for i in '(1 3 5 6 8 10 14 17)

and even with the mapcar function:

(mapcar #'print '(1 3 5 6 8 10 14 17))

D

{{Main|D (programming language)}}

foreach(item; set) {

}

or

foreach(argument) {

}

Dart

{{Main|Dart (programming language)}}

for (final element in someCollection) {

}

Object Pascal, Delphi

{{Main|Object Pascal}}

Foreach support was added in Delphi 2005, and uses an enumerator variable that must be declared in the var section.

for enumerator in collection do

begin

end;

Eiffel

The iteration (foreach) form of the Eiffel loop construct is introduced by the keyword across.

In this example, every element of the structure my_list is printed:

The local entity ic is an instance of the library class ITERATION_CURSOR. The cursor's feature item provides access to each structure element. Descendants of class ITERATION_CURSOR can be created to handle specialized iteration algorithms. The types of objects that can be iterated across (my_list in the example) are based on classes that inherit from the library class ITERABLE.

The iteration form of the Eiffel loop can also be used as a boolean expression when the keyword loop is replaced by either all (effecting universal quantification) or some (effecting existential quantification).

This iteration is a boolean expression which is true if all items in my_list have counts greater than three:

The following is true if at least one item has a count greater than three:

Go

Go's foreach loop can be used to loop over an array, slice, string, map, or channel.

Using the two-value form, we get the index/key (first element) and the value (second element):

for index, value := range someCollection {

// Do something to index and value

}

Using the one-value form, we get the index/key (first element):

for index := range someCollection {

// Do something to index

}

[7]

Groovy

Groovy supports for loops over collections like arrays, lists and ranges:

def x = [1,2,3,4]

for (v in x) // loop over the 4-element array x

{

}

for (v in [1,2,3,4]) // loop over 4-element literal list

{

}

for (v in 1..4) // loop over the range 1..4

{

}

Groovy also supports a C-style for loop with an array index:

for (i = 0; i < x.size(); i++)

{

}

Collections in Groovy can also be iterated over using the each keyword

and a closure. By default, the loop dummy is named it

x.each{ println it } // print every element of the x array

x.each{i-> println i} // equivalent to line above, only loop dummy explicitly named "i"

Haskell

Haskell allows looping over lists with monadic actions using mapM_ and forM_ (mapM_ with its arguments flipped) from Control.Monad:

mapM_ print [1..4]

 1 2 3 4

forM_ "test" $ \\char -> do

    putChar char    putChar char
code prints

It's also possible to generalize those functions to work on applicative functors rather than monads and any data structure that is traversable using traverse (for with its arguments flipped) and mapM (forM with its arguments flipped) from Data.Traversable.

Haxe

{{Main|Haxe}}

for (value in iterable) {

}

Lambda.iter(iterable, function(value) trace(value));

Java

In Java, a foreach-construct was introduced in Java Development Kit (JDK) 1.5.0.[8]

Official sources use several names for the construct. It is referred to as the "Enhanced for Loop",[8] the "For-Each Loop",[9] and the "foreach statement".[10]

for (Type item : iterableCollection) {

}

JavaScript

For unordered iteration over the keys in an Object, JavaScript features the for...in loop:

for (var key in object) {

}

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, if supported by the JavaScript engine (for WebKit/Safari, this means "in version 3 or later").

for (var key in object) {

    if (object.hasOwnProperty(key)) {        // Do stuff with object[key]    }

}

In ECMAScript 5 it is possible to use the keys method of the Object function to iterate over the own keys of an object more naturally.

[11]

var book = { name: "A Christmas Carol", author: "Charles Dickens" };

Object.keys(book).forEach(function (key, index) {

}

In ECMAScript 5 it's also possible to use the forEach method of a native array.[12]

var animals = ['dog', 'cat', 'bear'];

animals.forEach(function(animal, index) {

});

Gecko’s JavaScript engine also has a for each...in statement, which iterates over the values in the object, not the keys.[13]

It is inadvisable to use either a for...in or for each...in statement on an Array object in JavaScript, due to the above issue of properties inherited from prototypes, and also because it only iterates over existent keys and is not guaranteed to iterate over the elements in any particular order.[14] A regular C-style for loop should be used instead. The EcmaScript 6 standard has [https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/for...of for..of] for index-less iteration over generators, arrays and more.

Lua[15]

{{Main|Lua (programming language)}}

Iterate only through numerical index values:

for index, value in ipairs(array) do

-- do something

end

Iterate through all index values:

for index, value in pairs(array) do

-- do something

end

Mathematica

{{Main|Mathematica}}

In Mathematica, Do will simply evaluate an expression for each element of a list, without returning any value.

In[]:= Do[doSomethingWithItem, {item, list}]

It is more common to use Table, which returns the result of each evaluation in a new list.

In[]:= list = {3, 4, 5};

In[]:= Table[item^2, {item, list}]

Out[]= {9, 16, 25}

MATLAB

{{Main|MATLAB}}

for item = array

%do something

end

Mint

For each loops are supported in Mint, possessing the following syntax:

for each element of list

end

The for (;;) or while (true) infinite loop

in Mint can be written using a for each loop and an infinitely long list.[16]

import type

/* 'This function is mapped to'

 * 'each index number i of the' * 'infinitely long list.' */

sub identity(x)

end

/* 'The following creates the list'

 * '[0, 1, 2, 3, 4, 5, ..., infinity]' */

infiniteList = list(identity)

for each element of infiniteList

end

Objective-C

Foreach loops, called 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.

NSArray *a = [NSArray new]; // Any container class can be substituted

for(id obj in a) { // Note the dynamic typing (we do not need to know the

                                  // Type of object stored in 'a'.  In fact, there can be                                  // many different types of object in the array.
    printf("%s\", [[obj description] UTF8String]);  // Must use UTF8String with %s    NSLog(@"%@", obj);                               // Leave as an object

}

NSArrays can also broadcast a message to their members:

NSArray *a = [NSArray new];

[a makeObjectsPerformSelector:@selector(printDescription)];

Where blocks are available, an NSArray can automatically perform a block on every contained item:

[myArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)

{

NSLog(@"obj %@", obj);

if ([obj shouldStopIterationNow])

*stop = YES;

}];

The type of collection being iterated will dictate the item returned with each iteration.

For example:

NSDictionary *d = [NSDictionary new];

for(id key in d) {

    NSObject *obj = [d objectForKey:key];      // We use the (unique) key to access the (possibly nonunique) object.    NSLog(@"%@", obj);

}

OCaml

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:

List.iter (fun x -> print_int x) [1;2;3;4];;

or in short way:

List.iter print_int [1;2;3;4];;

For arrays:

Array.iter (fun x -> print_int x) [|1;2;3;4|];;

or in short way:

Array.iter print_int [|1;2;3;4|];;

ParaSail

The ParaSail parallel programming language supports several kinds of iterators, including a general "for each" iterator over a container:

var Con : Container := ...

// ...

for each Elem of Con concurrent loop // loop may also be "forward" or "reverse" or unordered (the default)

end loop

ParaSail also supports filters on iterators, and the ability to refer to both the key and the value of a map. Here is a forward iteration over the elements of "My_Map" selecting only elements where the keys are in "My_Set":

var My_Map : Map Univ_String, Value_Type => Tree> := ...

const My_Set : Set := ["abc", "def", "ghi"];

for each [Str => Tr] of My_Map {Str in My_Set} forward loop

end loop

Pascal

In Pascal, ISO standard 10206:1990 introduced iteration over set types, thus:

var

  elt: ElementType;  eltset: set of ElementType;
{...}

for elt in eltset do

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.

List literal example:

foreach (1, 2, 3, 4) {

}

Array examples:

foreach (@arr) {

}

foreach $x (@arr) { #$x is the element in @arr

}

Hash example:

foreach $x (keys %hash) {

}

Direct modification of collection members:

@arr = ( 'remove-foo', 'remove-bar' );

foreach $x (@arr){

}

  1. Now @arr = ('foo', 'bar');

Perl 6

In Perl 6, a distinct language from Perl 5, for must be used to traverse elements of a list. (foreach is no longer 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).

List literal example:

for 1..4 {

}

Array examples:

for @arr {

}

The for loop in its statement modifier form:

.say for @arr;

for @arr -> $x {

}

for @arr -> $x, $y { # more than one item at a time

}

Hash example:

for keys %hash -> $key {

}

or

for %hash.kv -> $key, $value {

}

or

for %hash -> $x {

}

Direct modification of collection members with a doubly pointy block, <->:

my @arr = 1,2,3;

for @arr <-> $x {

}

  1. Now @arr = 2,4,6;

PHP

{{Main|PHP}}

foreach ($set as $value)

{

}

It is also possible to extract both keys and values using the alternate syntax:

foreach ($set as $key => $value) {

}

Direct modification of collection members:

$arr = array(1, 2, 3);

foreach ($arr as &$value) { // Note the &, $value is a reference to the original value inside $arr

}

// Now $arr = array(2, 3, 4);

// also works with the full syntax

foreach ($arr as $key => &$value) {

}

  • More information

Python

{{Main|Python (programming language)}}

for item in iterable_collection:

Python's tuple assignment, fully available in its foreach loop, also makes it trivial to iterate on (key, value) pairs in associative arrays:

for key, value in some_dict.items(): # direct iteration on a dict iterates on its keys

As for ... in is the only kind of for loop in Python, the equivalent to the "counter" loop found in other languages is...

for i in range(len(seq)):

... though using the enumerate function is considered more "Pythonic":

for i, item in enumerate(seq):

    # do stuff with item    # possibly assign it back to seq[i]

Racket

{{Main|Racket (programming language)}}

(for ([item set])

or using the conventional Scheme for-each function:

(for-each do-something-with a-list)

do-something-with is a one-argument function.

Ruby

{{Main|Ruby (programming language)}}

set.each do |item|

end

or

for item in set

end

This can also be used with a hash.

set.each do |item,value|

  # do something to item  # do something to value

end

Scala

{{Main|Scala (programming language)}}

// return list of modified elements

items map { x => doSomething(x) }

items map multiplyByTwo

for {x <- items} yield doSomething(x)

for {x <- items} yield multiplyByTwo(x)

// return nothing, just perform action

items foreach { x => doSomething(x) }

items foreach println

for {x <- items} doSomething(x)

for {x <- items} println(x)

Scheme

{{Main|Scheme (programming language)}}

(for-each do-something-with a-list)

do-something-with is a one-argument function.

Smalltalk

{{Main|Smalltalk}}

collection do: [:item| "do something to item" ]

Swift

Swift uses the forin construct to iterate over members of a collection.[17]

for thing in someCollection {

}

The forin loop is often used with the closed and half-open range constructs to iterate over the loop body a certain number of times.

for i in 0..<10 {

    // 0..<10 constructs a half-open range, so the loop body    // is repeated for i = 0, i = 1, …, i = 9.

}

for i in 0...10 {

    // 0...10 constructs a closed range, so the loop body    // is repeated for i = 0, i = 1, …, i = 9, i = 10.

}

SystemVerilog

SystemVerilog supports iteration over any vector or array type of any dimensionality using the foreach keyword.

A trivial example iterates over an array of integers:

int array_1d[] = '{ 3, 2, 1, 0 };

foreach array_1d[index]

 array_1d[0]: 3 array_1d[1]: 2 array_1d[2]: 1 array_1d[3]: 0
code prints

A more complex example iterates over an associative array of arrays of integers:

int array_2d[string][] = '{ "tens": '{ 10, 11 },

foreach array_2d[key,index]

 array_2d[tens,0]: 10 array_2d[tens,1]: 11 array_2d[twenties,0]: 20 array_2d[twenties,1]: 21
code prints

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.

foreach {i j} {1 2 3 4 5 6} {

}

 1 2 3 4 5 6
code prints

It is also possible to iterate over more than one list simultaneously. In the following i assumes sequential values of the first list, j sequential values of the second list:

foreach i {1 2 3} j {a b c} {

}

 1 a 2 b 3 c
code prints

Visual Basic .NET

{{Main|Visual Basic .NET}}

For Each item In enumerable

Next

or without type inference

For Each item As type In enumerable

Next

Windows

Conventional command processor

{{main|COMMAND.COM|cmd.exe}}

Invoke a hypothetical frob command three times, giving it a color name each time.

C:\\>FOR %a IN ( red green blue ) DO frob %a

Windows PowerShell

{{Main|Windows PowerShell}}

foreach ($item in $set) {

}

From a pipeline

$list | ForEach-Object {Write-Host $_}

  1. or using the aliases

$list | foreach {write $_}

$list | % {write $_}

Extensible Stylesheet Language (XSL)

{{Main|XSL}}[18]

See also

  • Do while loop
  • For loop
  • While loop
  • Map (higher-order function)

References

1. ^{{cite web| url=http://www.digitalmars.com/d/statement.html#ForeachStatement| title=D Programming Language foreach Statement Documentation| accessdate=2008-08-04| last=| first=| coauthors=| date=| work=| publisher=Digital Mars}}
2. ^{{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 |accessdate=2013-08-04}}
3. ^{{cite web|url=https://en.cppreference.com/w/cpp/language/range-for |title=Range-based for loop (since C++11) |publisher=en.cppreference.com |date= |accessdate=2018-12-03}}
4. ^{{cite web|url=http://en.cppreference.com/w/cpp/algorithm/for_each |title=std::for_each - cppreference |publisher=en.cppreference.com |date= |accessdate=2017-09-30}}
5. ^{{cite web|url=http://doc.qt.digia.com/4.2/containers.html#the-foreach-keyword |title=Qt 4.2: Generic Containers |publisher=Doc.qt.digia.com |date= |accessdate=2013-08-04}}
6. ^{{cite web|author=Eric Niebler |url=http://www.boost.org/doc/libs/1_53_0/doc/html/foreach.html |title=Chapter 9. Boost.Foreach - 1.53.0 |publisher=Boost.org |date=2013-01-31 |accessdate=2013-08-04}}
7. ^{{cite web | url=http://golang.org/ref/spec#RangeClause | title=Range Clause | publisher=The Go Programming Language | work=The Go Programming Language Specification | accessdate=October 20, 2013}}
8. ^"Enhanced for Loop - This new language construct[...]"{{cite web|url=http://java.sun.com/j2se/1.5.0/docs/guide/language/index.html|title=Java Programming Language, Section: Enhancements in JDK 5|accessdate=2009-05-26|year=2004|publisher=Sun Microsystems, Inc.}}
9. ^"The For-Each Loop"{{cite web|url=http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html|title=The For-Each Loop|accessdate=2009-05-10|year=2008|publisher=Sun Microsystems, Inc.}}
10. ^"Implementing this interface allows an object to be the target of the "foreach" statement."{{cite web|url=http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html|title=Iterable (Java Platform SE 6)|accessdate=2009-05-12|year=2004|publisher=Sun Microsystems, Inc.}}
11. ^{{cite web | url= https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys | title=Object.keys | work=Mozilla Developer Network | accessdate=May 7, 2014}}
12. ^{{cite web | url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FArray%2FforEach | title=Array.prototype.forEach | work=Mozilla Developer Network | accessdate=October 20, 2013}}
13. ^{{cite web | url=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/for_each...in | title=JavaScript - for each...in statement | work=Mozilla Developer Network | accessdate=2008-10-03}}
14. ^{{cite web | url=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/for...in#Description | title=JavaScript - for...in statement on arrays | work=Mozilla Developer Network | accessdate=2008-10-03}}
15. ^{{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}}
16. ^{{cite web |url=http://prezi.com/ougvv1wzx2lb/mint-tutorial-part-0/ |title=Mint Tutorial |accessdate=20 October 2013 |author=Chu, Oliver}}
17. ^https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_language/ControlFlow.html#//apple_ref/doc/uid/TP40014097-CH9-XID_153
18. ^{{cite web | url=https://www.w3schools.com/xsl/xsl_for_each.asp | title=XSLT Element | work=W3Schools.com}}
Цикл просмотра

11 : Articles with example Ada code|Articles with example Perl code|Articles with example PHP code|Articles with example Python code|Articles with example Racket code|Articles with example Smalltalk code|Articles with example Tcl code|Control flow|Programming language comparisons|Articles with example Java code|Articles with example Haskell code

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/24 14:22:19