Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
For loop
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===1968: ALGOL 68=== {{Further|ALGOL 68}} ALGOL 68 has what was considered ''the'' universal loop, the full syntax is: <pre> FOR i FROM 1 BY 2 TO 3 WHILE iβ 4 DO ~ OD </pre> Further, the single iteration range could be replaced by a list of such ranges. There are several unusual aspects of the construct * only the {{code|do ~ od}} portion was compulsory, in which case the loop will iterate indefinitely. * thus the clause {{code|to 100 do ~ od}}, will iterate exactly 100 times. * The {{code|while}} ''syntactic element'' allowed a programmer to break from a {{code|for}} loop early, as in: <pre> INT sum sq := 0; FOR i WHILE print(("So far:", i, new line)); # Interposed for tracing purposes. # sum sq β 70β2 # This is the test for the WHILE # DO sum sq +:= iβ2 OD </pre> Subsequent ''extensions'' to the standard ALGOL 68 allowed the {{code|to}} syntactic element to be replaced with {{code|{{sic|hide=y|up|to}}}} and {{code|downto}} to achieve a small optimization. The same compilers also incorporated: ;{{code|until}}: for late loop termination. ;{{code|foreach}}: for working on arrays in [[parallel computing|parallel]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)