Loops/Infinite: Difference between revisions

Content added Content deleted
No edit summary
(Better D entry)
Line 168:
 
=={{header|D}}==
Some common ways to create an infinite printing loop:
<lang d>while(1) writeln("SPAM") ;
<lang d>import std.stdio;
 
void main() {
do writeln("SPAM"); while(1);
while (true)
<lang d>while(1) writeln("SPAM") ;
}</lang>
 
<lang d>import std.stdio;
for(;;) writeln("SPAM") ;
 
void main() {
l: writeln("SPAM"); goto l;
do
</lang>
for(;;) writeln("SPAM") ;
while (true);
}</lang>
 
<lang d>import std.stdio;
 
void main() {
for (;;)
l: writeln("SPAM"); goto l;
}</lang>
 
<lang d>import std.stdio;
 
void main() {
LOOP:
do writeln("SPAM"); while(1);
goto LOOP;
}</lang>
 
=={{header|dc}}==