Loops/Infinite: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
m (→‎{{header|GlovePIE}}: The description is more specific.)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 106:
: inf repeat "SPAM\n" . again ;
</lang>
 
=={{header|ACL2}}==
<lang Lisp>(defun spam ()
Line 171 ⟶ 172:
ENDLOOP
ENDPROC</lang>
 
=={{header|AppleScript}}==
<lang applescript>repeat
Line 303 ⟶ 305:
<lang bootBASIC>10 print "SPAM"
20 run</lang>
 
=={{header|Bracmat}}==
<lang bracmat>whl'out$SPAM</lang>
 
=={{header|Brainf***}}==
Line 314 ⟶ 319:
83+++ > 80 > 65+++++ > 77--- <<<
[.>.>.>.>.<<<<]</lang>
 
=={{header|Bracmat}}==
<lang bracmat>whl'out$SPAM</lang>
 
=={{header|Brat}}==
Line 335 ⟶ 337:
</lang>
 
=={{header|ChucKC sharp|C#}}==
 
<lang>
<lang csharp>while (true) <<<"SPAM">>>;
{
</lang>
Console.WriteLine("SPAM");
}</lang>
 
=={{header|C++}}==
Line 351 ⟶ 355:
std::cout << "SPAM\n";
while (true);</lang>
 
=={{header|C sharp|C#}}==
 
<lang csharp>while (true)
{
Console.WriteLine("SPAM");
}</lang>
 
=={{header|Chapel}}==
<lang chapel>while true do writeln("SPAM");</lang>
 
=={{header|ColdFusionChucK}}==
<lang>
This will result in a JRun Servlet Error and heap dump.
while(true) <<<"SPAM">>>;
 
</lang>
With tags:
<lang cfm><cfloop condition = "true NEQ false">
SPAM
</cfloop></lang>
With script:
<lang cfm><cfscript>
while( true != false )
{
writeOutput( "SPAM" );
}
</cfscript></lang>
 
=={{header|Clojure}}==
Line 398 ⟶ 385:
</lang>
 
=={{header|ColdFusion}}==
This will result in a JRun Servlet Error and heap dump.
 
With tags:
<lang cfm><cfloop condition = "true NEQ false">
SPAM
</cfloop></lang>
With script:
<lang cfm><cfscript>
while( true != false )
{
writeOutput( "SPAM" );
}
</cfscript></lang>
 
=={{header|Comal}}==
Line 469 ⟶ 470:
the outer ''dx'' makes the first call,
and the inner ''dx'' makes each recursive call.
 
=={{header|DCL}}==
<lang DCL>$ loop:
$ write sys$output "SPAM"
$ goto loop</lang>
 
=={{header|Déjà Vu}}==
<lang dejavu>while true:
!print "SPAM"</lang>
Infinite recursion thanks to tail calls:
<lang dejavu>labda:
!print "SPAM"
recurse
call</lang>
 
=={{header|Delphi}}==
Line 497 ⟶ 490:
print("SPAM")
}</lang>
 
=={{header|Déjà Vu}}==
<lang dejavu>while true:
!print "SPAM"</lang>
Infinite recursion thanks to tail calls:
<lang dejavu>labda:
!print "SPAM"
recurse
call</lang>
 
=={{header|E}}==
Line 596 ⟶ 598:
or
<lang elixir>Stream.cycle(["SPAM"]) |> Enum.each(&IO.puts &1)</lang>
 
=={{header|Emacs Lisp}}==
This is run in an external file.
<lang elisp>
#!/usr/bin/env emacs --script
 
(while (princ "SPAM\n"))
</lang>
 
=={{header|Erlang}}==
Line 605 ⟶ 615:
io:fwrite( "SPAM~n" ),
main().
</lang>
 
=={{header|Emacs Lisp}}==
This is run in an external file.
<lang elisp>
#!/usr/bin/env emacs --script
 
(while (princ "SPAM\n"))
</lang>
 
Line 1,005 ⟶ 1,007:
}
</lang>
 
 
=={{header|M4}}==
Line 1,034 ⟶ 1,035:
=={{header|Maxima}}==
<lang maxima>do(disp("SPAM"));</lang>
 
=={{header|MAXScript}}==
<lang maxscript>while true do print "SPAM\n"</lang>
Line 1,081 ⟶ 1,083:
traceln("SPAM")
</lang>
 
=={{header|MontiLang}}==
<lang MontiLang>WHILE TRUE
|SPAM| PRINT .
ENDWHILE</lang>
Note that <code>TRUE</code> is simply a variable equal to 1. <code>WHILE 1</code>, any number larger than 0 or any string with a length more than 0 would also work
 
=={{header|MOO}}==
Line 1,086 ⟶ 1,094:
player:tell("SPAM");
endwhile</lang>
 
=={{header|MUMPS}}==
<lang MUMPS>
FOR WRITE "SPAM",!
</lang>
 
=={{header|MontiLang}}==
<lang MontiLang>WHILE TRUE
|SPAM| PRINT .
ENDWHILE</lang>
Note that <code>TRUE</code> is simply a variable equal to 1. <code>WHILE 1</code>, any number larger than 0 or any string with a length more than 0 would also work
 
=={{header|Nanoquery}}==
Line 1,241 ⟶ 1,244:
 
<lang perl>print "SPAM\n" while 1;</lang>
 
=={{header|Perl 6}}==
{{works with|Rakudo Star|2010.08}}
 
<lang perl6>loop {
say 'SPAM';
}</lang>
In addition, there are various ways of writing lazy, infinite lists in Perl&nbsp;6:
<lang perl6>print "SPAM\n" xx *; # repetition operator
print "SPAM\n", ~* ... *; # sequence operator
map {say "SPAM"}, ^Inf; # upto operator</lang>
 
=={{header|Phix}}==
Line 1,381 ⟶ 1,373:
(displayln "SPAM"))
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo Star|2010.08}}
 
<lang perl6>loop {
say 'SPAM';
}</lang>
In addition, there are various ways of writing lazy, infinite lists in Perl&nbsp;6:
<lang perl6>print "SPAM\n" xx *; # repetition operator
print "SPAM\n", ~* ... *; # sequence operator
map {say "SPAM"}, ^Inf; # upto operator</lang>
 
=={{header|REBOL}}==
Line 1,447 ⟶ 1,451:
<lang ruby>loop {puts "SPAM"}
</lang>
 
=={{header|Rust}}==
<lang rust>fn main() {
loop {
println!("SPAM");
}
}</lang>
 
=={{header|Run BASIC}}==
Line 1,462 ⟶ 1,459:
wend</lang>
 
=={{header|Rust}}==
<lang rust>fn main() {
loop {
println!("SPAM");
}
}</lang>
 
=={{header|S-lang}}==
Line 1,590 ⟶ 1,593:
#.output("SPAM")
<</lang>
 
=={{header|Standard ML}}==
<lang sml>while true do
print "SPAM\n";</lang>
 
or
 
<lang sml>let
fun inf_loop () = (
print "SPAM\n";
inf_loop ()
)
in
inf_loop ()
end</lang>
 
Seen like this it looks like the "too much functional" danger when a "while" loop looks far simpler, but the functional loop may be useful to provide data to the next loop without using mutable variable.
 
=={{header|Stata}}==
 
<lang stata>while 1 {
display "SPAM"
}</lang>
 
=== Mata ===
<lang stata>while (1) printf("SPAM\n")</lang>
 
Also possible with a '''[https://www.stata.com/help.cgi?m2_for for]''' loop, but unlike C, the middle expression is not optional:
 
<lang stata>for (;1;) printf("SPAM\n")</lang>
 
=={{header|SQL PL}}==
Line 1,655 ⟶ 1,628:
...
</pre>
 
=={{header|Standard ML}}==
<lang sml>while true do
print "SPAM\n";</lang>
 
or
 
<lang sml>let
fun inf_loop () = (
print "SPAM\n";
inf_loop ()
)
in
inf_loop ()
end</lang>
 
Seen like this it looks like the "too much functional" danger when a "while" loop looks far simpler, but the functional loop may be useful to provide data to the next loop without using mutable variable.
 
=={{header|Stata}}==
 
<lang stata>while 1 {
display "SPAM"
}</lang>
 
=== Mata ===
<lang stata>while (1) printf("SPAM\n")</lang>
 
Also possible with a '''[https://www.stata.com/help.cgi?m2_for for]''' loop, but unlike C, the middle expression is not optional:
 
<lang stata>for (;1;) printf("SPAM\n")</lang>
 
=={{header|Swift}}==
Line 1,667 ⟶ 1,670:
endprogram
</lang>
 
=={{header|Transact-SQL}}==
 
<lang sql>WHILE 1=1 BEGIN
PRINT "SPAM"
END</lang>
 
=={{header|Tcl}}==
Line 1,710 ⟶ 1,707:
<lang Torque>While(1)
echo("SPAM");</lang>
 
=={{header|Transact-SQL}}==
 
<lang sql>WHILE 1=1 BEGIN
PRINT "SPAM"
END</lang>
 
=={{header|Trith}}==
Line 1,768 ⟶ 1,771:
<lang vala>while(true) stdout.printf("SPAM\n");</lang>
<lang vala>do stdout.printf("SPAM\n"); while(true);</lang>
 
=={{header|VAX Assembly}}==
<lang VAX Assembly> 0000 0000 1 .entry main,0
10,333

edits