Loops/Foreach: Difference between revisions

Add ed example
(Add ed example)
 
(4 intermediate revisions by 3 users not shown)
Line 1,238:
5
</pre>
 
=={{header|Ed}}==
 
Print all (newline-separated) lines in the file.
 
}</syntaxhighlight lang="sed">
,p
</syntaxhighlight>
 
=={{header|Efene}}==
Line 1,842 ⟶ 1,850:
 
=={{header|langur}}==
A for in loop iterates over values and a for of loop iterates over indiceskeys.
<syntaxhighlight lang="langur">for .i in [1, 2, 3] {
for i in [1, 2, 3] {
writeln .i
}
 
val .abc = "abc"
 
for .i in .abc {
writeln .i
}
 
for .i of .abc {
writeln .abc[.i]
}
 
for .i in .abc {
writeln cp2s .(i)
}
}</syntaxhighlight>
</syntaxhighlight>
 
{{out}}
Line 2,187 ⟶ 2,197:
{{works with|Cocoa}}
<syntaxhighlight lang="objc">NSArray *collect;
// ...
for (Type i in collect) {
NSLog(@"%@", i);
}</syntaxhighlight>
Line 2,196 ⟶ 2,206:
{{works with|Objective-C|<2.0}}
<syntaxhighlight lang="objc">NSArray *collect;
// ...
NSEnumerator *enm = [collect objectEnumerator];
id i;
while( ((i = [enm nextObject]) ) {
// do something with object i
}</syntaxhighlight>
Line 2,299 ⟶ 2,309:
=={{header|Pascal}}==
See [[Loops/Foreach#Delphi | Delphi]]
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
##
foreach var s in |'Pascal','ABC','.NET'| do
Print(s);
</syntaxhighlight>
 
=={{header|Perl}}==
110

edits