Loops/Foreach: Difference between revisions

Add ooRexx implementation
(→‎{{header|REXX}}: deleted versions not compliant with task description, that is: use a DO .. FOR.. construct. -- ~~~~)
(Add ooRexx implementation)
Line 871:
disp(val);
endfor</lang>
 
=={{header|ooRexx}}==
The <tt>OVER</tt> loop control keyword is used to select each item in a collection in turn.
Open Object Rexx allows the <tt>DO</tt> block structure keyword to be used to start a loop for backward compatibility with classic Rexx; the <tt>LOOP</tt> keyword is preferred here as it is self-documenting.
<lang ooRexx>/* Rexx */
say
say 'Loops/Foreach'
out = ''
 
days = .array~of('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
 
loop daysi over days
out ||= daysi' '
end daysi
say out~strip()
 
exit
</lang>
'''Output:'''
<pre>
Loops/Foreach
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
</pre>
 
=={{header|Oz}}==
Anonymous user