Loops/Infinite: Difference between revisions
< Loops
Content added Content deleted
(Made into a task) |
No edit summary |
||
Line 21: | Line 21: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
<pre language="java">while(true){ |
|||
<java>while(true){//anything that always evaluates to true is OK (1==1, for example) |
|||
System.out.println("SPAM"); |
System.out.println("SPAM"); |
||
}</ |
}</pre> |
||
Or: |
|||
<java>for(;;){ |
<pre language="java">for(;;){ |
||
System.out.println("SPAM"); |
System.out.println("SPAM"); |
||
} |
} |
||
</ |
</pre> |
||
=={{header|Logo}}== |
=={{header|Logo}}== |
||
Line 49: | Line 49: | ||
=={{header|UnixPipes}}== |
=={{header|UnixPipes}}== |
||
<pre language="unixpipes">while true ; do echo "YES" ; done</pre> |
|||
yes SPAM |
Revision as of 13:55, 11 April 2008
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
Specifically print out "SPAM" followed by a newline in an infinite loop.
Ada
loop Put_Line("SPAM"); end loop;
C
while(1) puts("SPAM");
Common Lisp
(loop (write-line "SPAM"))
Groovy
while (true) { println 'SPAM' }
Haskell
forever (putStrLn "SPAM")
Java
while(true){ System.out.println("SPAM"); }
for(;;){ System.out.println("SPAM"); }
Logo
forever [print "SPAM]
Perl
while(1){print"SPAM\n"}
Prolog
repeat, write('SPAM'), nl, fail.
Python
while 1: print "SPAM"
Ruby
while true do puts "SPAM" end
UnixPipes
while true ; do echo "YES" ; done