Loops/Infinite: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎{{header|Ada}}: Added syntax highlighting)
(+ MAXScript)
Line 32: Line 32:
=={{header|Logo}}==
=={{header|Logo}}==
<pre language="logo">forever [print "SPAM]</pre>
<pre language="logo">forever [print "SPAM]</pre>

=={{header|MAXScript}}==
<pre language="maxscript">while true do print "SPAM\n"</pre>


=={{header|Perl}}==
=={{header|Perl}}==

Revision as of 18:43, 11 April 2008

Task
Loops/Infinite
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>

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");
}

forever [print "SPAM]

MAXScript

while true do print "SPAM\n"

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