Loops/Infinite: Difference between revisions
< Loops
Content added Content deleted
m (→{{header|Pascal}}: oops ... wrong closing tag) |
(→{{header|UnixPipes}}: corrected example (task: print SPAM, not YES)) |
||
Line 73: | Line 73: | ||
=={{header|UnixPipes}}== |
=={{header|UnixPipes}}== |
||
<pre language="unixpipes">while true ; do echo " |
<pre language="unixpipes">while true ; do echo "SPAM" ; done</pre> |
Revision as of 19:09, 18 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>
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
while true ; do echo "SPAM" ; done