Loops/Infinite: Difference between revisions
< Loops
Content added Content deleted
(→{{header|Java}}: Syntax highlighting, added infinite for) |
|||
Line 22: | Line 22: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
<java>while(true){//anything that always evaluates to true is OK (1==1, for example) |
|||
<pre language="java">while(true) { |
|||
System.out.println("SPAM"); |
System.out.println("SPAM"); |
||
}</ |
}</java> |
||
Or: |
|||
<java>for(;;){ |
|||
System.out.println("SPAM"); |
|||
} |
|||
</java> |
|||
=={{header|Logo}}== |
=={{header|Logo}}== |
Revision as of 12:42, 11 April 2008
Perform the same series of actions indefinitely.
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
<java>while(true){//anything that always evaluates to true is OK (1==1, for example)
System.out.println("SPAM");
}</java> Or: <java>for(;;){
System.out.println("SPAM");
} </java>
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
yes SPAM