Loops/Infinite: Difference between revisions
< Loops
Content added Content deleted
m (Got rid of that "pre language=" stuff that still doesn't work here) |
|||
Line 31: | Line 31: | ||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
while (true) { |
|||
println 'SPAM' |
println 'SPAM' |
||
} |
|||
}</pre> |
|||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
forever (putStrLn "SPAM") |
|||
=={{header|Java}}== |
=={{header|Java}}== |
||
Line 52: | Line 52: | ||
=={{header|Logo}}== |
=={{header|Logo}}== |
||
forever [print "SPAM] |
|||
=={{header|MAXScript}}== |
=={{header|MAXScript}}== |
||
while true do print "SPAM\n" |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
Line 72: | Line 72: | ||
=={{header|Prolog}}== |
=={{header|Prolog}}== |
||
repeat, write('SPAM'), nl, fail. |
|||
=={{header|Python}}== |
=={{header|Python}}== |
||
Line 84: | Line 84: | ||
=={{header|UnixPipes}}== |
=={{header|UnixPipes}}== |
||
yes SPAM |
|||
<pre language="unixpipes">yes SPAM</pre> |
|||
=={{header|V}}== |
=={{header|V}}== |
Revision as of 22:39, 26 April 2008
Loops/Infinite
You are encouraged to solve this task according to the task description, using any language you may know.
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
<ada>loop
Put_Line("SPAM");
end loop;</ada>
BASIC
<qbasic>while 1 print "SPAM" wend</qbasic> Also <qbasic>for i = 1 to 10 step 0 print "SPAM" next i</qbasic>
With classic BASIC, the standard way to make an infinite loop would be:
10 PRINT "SPAM" 20 GOTO 10
C
<c>while(1) puts("SPAM");</c>
Common Lisp
<lisp>(loop (write-line "SPAM"))</lisp>
Forth
: email begin ." SPAM" cr again ;
Groovy
while (true) { println 'SPAM' }
Haskell
forever (putStrLn "SPAM")
Java
<java>while(true){
System.out.println("SPAM");
}</java>
<java>for(;;){
System.out.println("SPAM");
}</java>
JavaScript
for (;;) print("SPAM"); while (true) print("SPAM");
Logo
forever [print "SPAM]
MAXScript
while true do print "SPAM\n"
OCaml
<ocaml>while true do
print_endline "SPAM"
done</ocaml>
Pascal
<pascal> while true do
writeln('SPAM');
</pascal>
Perl
<perl>while(1){print"SPAM\n"}</perl>
Prolog
repeat, write('SPAM'), nl, fail.
Python
<python>while 1:
print "SPAM"</python>
Ruby
while true do
puts "SPAM"
end
UnixPipes
yes SPAM
V
true [ 'SPAM' puts ] while