Loops/Infinite: Difference between revisions
< Loops
Content added Content deleted
(+ MAXScript) |
(added ocaml, plus syntax highlighting) |
||
Line 7: | Line 7: | ||
=={{header|C}}== |
=={{header|C}}== |
||
< |
<c>while(1) puts("SPAM");</c> |
||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
< |
<lisp>(loop (write-line "SPAM"))</lisp> |
||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
Line 21: | Line 21: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
< |
<java>while(true){ |
||
System.out.println("SPAM"); |
System.out.println("SPAM"); |
||
}</ |
}</java> |
||
< |
<java>for(;;){ |
||
System.out.println("SPAM"); |
System.out.println("SPAM"); |
||
}</java> |
|||
} |
|||
</pre> |
|||
=={{header|Logo}}== |
=={{header|Logo}}== |
||
Line 35: | Line 34: | ||
=={{header|MAXScript}}== |
=={{header|MAXScript}}== |
||
<pre language="maxscript">while true do print "SPAM\n"</pre> |
<pre language="maxscript">while true do print "SPAM\n"</pre> |
||
=={{header|OCaml}}== |
|||
<ocaml>while true do |
|||
print_endline "SPAM" |
|||
done</ocaml> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<perl>while(1){print"SPAM\n"}</perl> |
||
=={{header|Prolog}}== |
=={{header|Prolog}}== |
||
Line 43: | Line 47: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
< |
<python>while 1: |
||
print "SPAM"</ |
print "SPAM"</python> |
||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<ruby>while true do |
||
puts "SPAM" |
puts "SPAM" |
||
end</ |
end</ruby> |
||
=={{header|UnixPipes}}== |
=={{header|UnixPipes}}== |
Revision as of 02:12, 12 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>
C
<c>while(1) puts("SPAM");</c>
Common Lisp
<lisp>(loop (write-line "SPAM"))</lisp>
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>
Logo
forever [print "SPAM]
MAXScript
while true do print "SPAM\n"
OCaml
<ocaml>while true do
print_endline "SPAM"
done</ocaml>
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 "YES" ; done