Loops/Infinite: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
m (→‎{{header|Ada}}: Added syntax highlighting)
Line 2: Line 2:


=={{header|Ada}}==
=={{header|Ada}}==
<pre language="ada">loop
<ada>loop
Put_Line("SPAM");
Put_Line("SPAM");
end loop;</pre>
end loop;</ada>


=={{header|C}}==
=={{header|C}}==

Revision as of 18:12, 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]

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