Loops/Infinite: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
 
(42 intermediate revisions by 33 users not shown)
Line 25: Line 25:


=={{header|11l}}==
=={{header|11l}}==
<lang 11l>L
<syntaxhighlight lang="11l">L
print(‘SPAM’)</lang>
print(‘SPAM’)</syntaxhighlight>


=={{header|360 Assembly}}==
=={{header|360 Assembly}}==
This for sure will result in a severe WTO buffer shortage.
This for sure will result in a severe WTO buffer shortage.
<syntaxhighlight lang="360 assembly">
<lang 360 Assembly>
INFINITE CSECT , this PGM control section
INFINITE CSECT , this PGM control section
INFINITE AMODE 31 addressing mode 31 bit
INFINITE AMODE 31 addressing mode 31 bit
Line 47: Line 47:
RETURN PR , return to caller
RETURN PR , return to caller
END INFINITE
END INFINITE
</syntaxhighlight>
</lang>


=={{header|4DOS Batch}}==
=={{header|4DOS Batch}}==


<lang 4dos>@echo off
<syntaxhighlight lang="4dos">@echo off
do forever
do forever
echo SPAM
echo SPAM
enddo</lang>
enddo</syntaxhighlight>


=={{header|6502 Assembly}}==
=={{header|6502 Assembly}}==
Specific OS/hardware routines for printing are left unimplemented.
Specific OS/hardware routines for printing are left unimplemented.
<lang 6502asm>InfiniteLoop LDX #0
<syntaxhighlight lang="6502asm">InfiniteLoop LDX #0
PrintLoop: LDA MSG,x
PrintLoop: LDA MSG,x
JSR PrintAccumulator ;routine not implemented
JSR PrintAccumulator ;routine not implemented
Line 66: Line 66:
BEQ InfiniteLoop
BEQ InfiniteLoop


MSG .byte "SPAM", $0A</lang>
MSG .byte "SPAM", $0A</syntaxhighlight>


=={{header|6800 Assembly}}==
=={{header|6800 Assembly}}==
<lang> .cr 6800
<syntaxhighlight lang="text"> .cr 6800
.tf spam6800.obj,AP1
.tf spam6800.obj,AP1
.lf spam6800
.lf spam6800
Line 99: Line 99:
;=====================================================;
;=====================================================;
string .as "SPAM",#13,#10,#0
string .as "SPAM",#13,#10,#0
.en</lang>
.en</syntaxhighlight>


=={{header|68000 Assembly}}==
=={{header|68000 Assembly}}==
Hardware-specific routines for I/O are left unimplemented and just displayed as a subroutine, as this is not the focus of the task.
Hardware-specific routines for I/O are left unimplemented and just displayed as a subroutine, as this is not the focus of the task.
<lang 68000devpac>doSPAM:
<syntaxhighlight lang="68000devpac">doSPAM:
LEA Message,A0
LEA Message,A0
JSR PrintString
JSR PrintString
Line 110: Line 110:
Message:
Message:
DC.B "SPAM",13,10,0
DC.B "SPAM",13,10,0
EVEN</lang>
EVEN</syntaxhighlight>


=={{header|8086 Assembly}}==
=={{header|8086 Assembly}}==
{{works with|https://www.dosbox.com DOSBox}}
{{works with|https://www.dosbox.com DOSBox}}
===Loading Immediates===
===Loading Immediates===
<lang asm>Spam:
<syntaxhighlight lang="asm">Spam:
mov ah,02h
mov ah,02h
mov dl,'S' ;VASM replaces a character in single quotes with its ascii equivalent
mov dl,'S' ;VASM replaces a character in single quotes with its ascii equivalent
Line 135: Line 135:
int 21h
int 21h


jmp Spam</lang>
jmp Spam</syntaxhighlight>


===Loading From A Data Source===
===Loading From A Data Source===
<lang asm>mov ah, 02h ;prep int 21h for printing to screen
<syntaxhighlight lang="asm">mov ah, 02h ;prep int 21h for printing to screen
mov ax, seg SpamMessage ;load into ax whatever segment the address of our message is in.
mov ax, seg SpamMessage ;load into ax whatever segment the address of our message is in.
mov ds, ax ;segment registers on the original 8086 must be loaded from a register
mov ds, ax ;segment registers on the original 8086 must be loaded from a register
Line 154: Line 154:
jmp SpamInner
jmp SpamInner


SpamMessage db "SPAM",13,10,0</lang>
SpamMessage db "SPAM",13,10,0</syntaxhighlight>


=={{header|8th}}==
=={{header|8th}}==
One way:
One way:
<lang forth>
<syntaxhighlight lang="forth">
: inf "SPAM\n" . recurse ;
: inf "SPAM\n" . recurse ;
</syntaxhighlight>
</lang>
Another way:
Another way:
<lang forth>
<syntaxhighlight lang="forth">
: inf repeat "SPAM\n" . again ;
: inf repeat "SPAM\n" . again ;
</syntaxhighlight>
</lang>
=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
<syntaxhighlight lang="aarch64 assembly">
<lang AArch64 Assembly>
/* ARM assembly AARCH64 Raspberry PI 3B */
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program infinite64.s */
/* program infinite64.s */
Line 201: Line 201:
/* for this file see task include a file in language AArch64 assembly */
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
.include "../includeARM64.inc"
</syntaxhighlight>
</lang>
=={{header|ACL2}}==
=={{header|ACL2}}==
<lang Lisp>(defun spam ()
<syntaxhighlight lang="lisp">(defun spam ()
(declare (xargs :mode :program))
(declare (xargs :mode :program))
(if nil
(if nil
nil
nil
(prog2$ (cw "SPAM~%")
(prog2$ (cw "SPAM~%")
(spam))))</lang>
(spam))))</syntaxhighlight>


=={{header|Action!}}==
=={{header|Action!}}==
<lang Action!>PROC Main()
<syntaxhighlight lang="action!">PROC Main()
DO
DO
PrintE("SPAM")
PrintE("SPAM")
OD
OD
RETURN</lang>
RETURN</syntaxhighlight>
{{out}}
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Infinite.png Screenshot from Atari 8-bit computer]
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Infinite.png Screenshot from Atari 8-bit computer]
Line 235: Line 235:


=={{header|ActionScript}}==
=={{header|ActionScript}}==
<lang actionscript>while (true) {
<syntaxhighlight lang="actionscript">while (true) {
trace("SPAM");
trace("SPAM");
}</lang>
}</syntaxhighlight>


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


=={{header|Agena}}==
=={{header|Agena}}==
Tested with Agena 2.9.5 Win32
Tested with Agena 2.9.5 Win32
<lang agena>do
<syntaxhighlight lang="agena">do
print( "SPAM" )
print( "SPAM" )
od</lang>
od</syntaxhighlight>


=={{header|Aime}}==
=={{header|Aime}}==
<lang aime>while (1) {
<syntaxhighlight lang="aime">while (1) {
o_text("SPAM\n");
o_text("SPAM\n");
}</lang>
}</syntaxhighlight>


=={{header|ALGOL 60}}==
=={{header|ALGOL 60}}==
Line 265: Line 265:
'''end'''
'''end'''
{{works with|ALGOL 60|OS/360}}
{{works with|ALGOL 60|OS/360}}
<lang algol60>'BEGIN' 'COMMENT' Loops/Infinite - Algol60 - 23/06/2018;
<syntaxhighlight lang="algol60">'BEGIN' 'COMMENT' Loops/Infinite - Algol60 - 23/06/2018;
'INTEGER' I;
'INTEGER' I;
'FOR' I := 1 'STEP' 0 'UNTIL' 2 'DO'
'FOR' I := 1 'STEP' 0 'UNTIL' 2 'DO'
OUTSTRING(1,'('SPAM')')
OUTSTRING(1,'('SPAM')')
'END'</lang>
'END'</syntaxhighlight>


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
<lang algol68>DO
<syntaxhighlight lang="algol68">DO
printf($"SPAM"l$)
printf($"SPAM"l$)
OD</lang>
OD</syntaxhighlight>
Or the classic "dynamic halt":
Or the classic "dynamic halt":
<lang algol68>loop x:
<syntaxhighlight lang="algol68">loop x:
printf($"SPAM"l$);
printf($"SPAM"l$);
loop x</lang>
loop x</syntaxhighlight>


=={{header|ALGOL W}}==
=={{header|ALGOL W}}==
<lang algolw>begin
<syntaxhighlight lang="algolw">begin
for i := 1 step 0 until 2 do write( "SPAM" )
for i := 1 step 0 until 2 do write( "SPAM" )
end.</lang>
end.</syntaxhighlight>


=={{header|AmigaE}}==
=={{header|AmigaE}}==
<lang amigae>PROC main()
<syntaxhighlight lang="amigae">PROC main()
LOOP
LOOP
WriteF('SPAM')
WriteF('SPAM')
ENDLOOP
ENDLOOP
ENDPROC</lang>
ENDPROC</syntaxhighlight>


=={{header|AppleScript}}==
=={{header|AppleScript}}==
<lang applescript>repeat
<syntaxhighlight lang="applescript">repeat
log "SPAM"
log "SPAM"
end repeat</lang>
end repeat</syntaxhighlight>


=={{header|ARM Assembly}}==
=={{header|ARM Assembly}}==
<syntaxhighlight lang="arm_assembly">
<lang ARM_Assembly>
.global main
.global main


Line 310: Line 310:
message:
message:
.asciz "SPAM\n"
.asciz "SPAM\n"
</syntaxhighlight>
</lang>


=={{header|ArnoldC}}==
=={{header|ArnoldC}}==
<lang ArnoldC>IT'S SHOWTIME
<syntaxhighlight lang="arnoldc">IT'S SHOWTIME
STICK AROUND @NO PROBLEMO
STICK AROUND @NO PROBLEMO
TALK TO THE HAND "SPAM"
TALK TO THE HAND "SPAM"
CHILL
CHILL
YOU HAVE BEEN TERMINATED</lang>
YOU HAVE BEEN TERMINATED</syntaxhighlight>


=={{header|Arturo}}==
=={{header|Arturo}}==
<lang rebol>while [true] [
<syntaxhighlight lang="rebol">while [true] [
print "SPAM"
print "SPAM"
]</lang>
]</syntaxhighlight>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang autohotkey>Loop
<syntaxhighlight lang="autohotkey">Loop
MsgBox SPAM `n</lang>
MsgBox SPAM `n</syntaxhighlight>


=={{header|AWK}}==
=={{header|AWK}}==
<lang awk>BEGIN {
<syntaxhighlight lang="awk">BEGIN {
while(1) {
while(1) {
print "SPAM"
print "SPAM"
}
}
}</lang>
}</syntaxhighlight>


=={{header|Axe}}==
=={{header|Axe}}==
Warning: running this program will cause you to need to reset your calculator, thereby losing any user data stored in RAM.
Warning: running this program will cause you to need to reset your calculator, thereby losing any user data stored in RAM.


<lang axe>While 1
<syntaxhighlight lang="axe">While 1
Disp "SPAM",i
Disp "SPAM",i
End</lang>
End</syntaxhighlight>


=={{header|BASIC}}==
=={{header|BASIC}}==
{{works with|QuickBasic|4.5}}
{{works with|QuickBasic|4.5}}
Old-fashioned syntax:
Old-fashioned syntax:
<lang qbasic>while 1
<syntaxhighlight lang="qbasic">while 1
print "SPAM"
print "SPAM"
wend</lang>
wend</syntaxhighlight>


Standard BASIC:
Standard BASIC:
<lang qbasic>do
<syntaxhighlight lang="qbasic">do
print "SPAM"
print "SPAM"
loop</lang>
loop</syntaxhighlight>


Also
Also
<lang qbasic>for i = 1 to 10 step 0
<syntaxhighlight lang="qbasic">for i = 1 to 10 step 0
print "SPAM"
print "SPAM"
next i</lang>
next i</syntaxhighlight>


{{works with|Applesoft BASIC}}
{{works with|Applesoft BASIC}}
{{works with|Commodore BASIC}}
{{works with|Commodore BASIC}}
{{works with|Tiny BASIC}}
{{works with|ZX Spectrum Basic}}
{{works with|ZX Spectrum Basic}}


The most intuitive method is to use the <code>GOTO</code> statement.
The most intuitive method is to use the <code>GOTO</code> statement.


<lang gwbasic>10 print "SPAM"
<syntaxhighlight lang="gwbasic">10 print "SPAM"
20 goto 10</lang>
20 goto 10</syntaxhighlight>


Generally, using <code>GOSUB</code> in place of <code>GOTO</code> is incorrect. Some programming bugs come about when a <code>GOSUB</code> causes a potentially infinite loop, however, eventually stack memory will fill up and cause a terminating error as shown in this Commodore BASIC example:
Generally, using <code>GOSUB</code> in place of <code>GOTO</code> is incorrect. Some programming bugs come about when a <code>GOSUB</code> causes a potentially infinite loop, however, eventually stack memory will fill up and cause a terminating error as shown in this Commodore BASIC example:
Line 386: Line 387:
The solution is to keep the stack empty, however, this will also clear all variables used and prevent the use of <code>RETURN</code>ing from the "subroutine". This is accomplished with the <code>CLEAR</code> (or <code>CLR</code> in Commodore BASIC) placed at the start of the loop.
The solution is to keep the stack empty, however, this will also clear all variables used and prevent the use of <code>RETURN</code>ing from the "subroutine". This is accomplished with the <code>CLEAR</code> (or <code>CLR</code> in Commodore BASIC) placed at the start of the loop.


<lang gwbasic>10 clr:print "Commodore Spam! ";:gosub 10</lang>
<syntaxhighlight lang="gwbasic">10 clr:print "Commodore Spam! ";:gosub 10</syntaxhighlight>
<lang gwbasic>10 clear : print "Apple Spam! ";: gosub 10</lang>
<syntaxhighlight lang="gwbasic">10 clear : print "Apple Spam! ";: gosub 10</syntaxhighlight>


Rather than a <code>GOTO</code>, instead we can use a <code>FOR... NEXT</code> statement:
Rather than a <code>GOTO</code>, instead we can use a <code>FOR... NEXT</code> statement:


<lang gwbasic>10 for i = 1 to 10 step 0 : rem A zero step makes the loop infinite
<syntaxhighlight lang="gwbasic">10 for i = 1 to 10 step 0 : rem A zero step makes the loop infinite
20 print "SPAM";
20 print "SPAM";
30 next i</lang>
30 next i</syntaxhighlight>


In most cases, we can also call the <code>RUN</code> command from within the program.
In most cases, we can also call the <code>RUN</code> command from within the program.


<lang gwbasic>10 print "Spam! ";
<syntaxhighlight lang="gwbasic">10 print "Spam! ";
20 run</lang>
20 run</syntaxhighlight>


<code>IF... THEN</code> has an implied <code>GOTO</code> on some BASICs...
<code>IF... THEN</code> has an implied <code>GOTO</code> on some BASICs...


<lang gwbasic>10 print "SPAM SPAM! ";:if 1 then 10</lang>
<syntaxhighlight lang="gwbasic">10 print "SPAM SPAM! ";:if 1 then 10</syntaxhighlight>


==={{header|Applesoft BASIC}}===
==={{header|Applesoft BASIC}}===
<lang ApplesoftBasic>FOR I = 0 TO 1 STEP 0 : PRINT "SPAM" : NEXT</lang>
<syntaxhighlight lang="applesoftbasic">FOR I = 0 TO 1 STEP 0 : PRINT "SPAM" : NEXT</syntaxhighlight>




==={{header|BASIC256}}===
==={{header|BASIC256}}===
<lang BASIC256>while true
<syntaxhighlight lang="basic256">while true
print "SPAM"
print "SPAM"
end while</lang>
end while</syntaxhighlight>


==={{header|Commodore BASIC}}===
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">10 while 1
20 print "SPAM"
30 wend</syntaxhighlight>


==={{header|Commodore BASIC}}===
In addition to the general examples listed above for [[#BASIC|BASIC]], there is a trick to get a Commodore BASIC program to endlessly loop its listing. All of the lines of code are a linked list in RAM. The trick is accomplished by modifying the pointer to the next line, which is recorded at the very start of each tokenized BASIC line. Instead of it pointing to the next line, you can make it point to a previous line, or itself. This will affect execution when any <code>GOTO</code> or <code>GOSUB</code> needs to reference any line number '''after''' the affected line, since the line search will be corrupted (and endless...)
In addition to the general examples listed above for [[#BASIC|BASIC]], there is a trick to get a Commodore BASIC program to endlessly loop its listing. All of the lines of code are a linked list in RAM. The trick is accomplished by modifying the pointer to the next line, which is recorded at the very start of each tokenized BASIC line. Instead of it pointing to the next line, you can make it point to a previous line, or itself. This will affect execution when any <code>GOTO</code> or <code>GOSUB</code> needs to reference any line number '''after''' the affected line, since the line search will be corrupted (and endless...)


Line 446: Line 452:
ready.
ready.
&#9608;</pre>
&#9608;</pre>

==={{header|Craft Basic}}===
<syntaxhighlight lang="text">
do
print "SPAM"
loop
</syntaxhighlight>

==={{header|GW-BASIC}}===
{{works with|PC-BASIC}}
<syntaxhighlight lang="qbasic">10 WHILE 1
20 PRINT "SPAM"
30 WEND</syntaxhighlight>
Also
<syntaxhighlight lang="qbasic">10 PRINT "SPAM"
20 GOTO 10</syntaxhighlight>


==={{header|IS-BASIC}}===
==={{header|IS-BASIC}}===
<lang IS-BASIC>100 DO
<syntaxhighlight lang="is-basic">100 DO
110 PRINT "SPAM"
110 PRINT "SPAM"
120 LOOP</lang>
120 LOOP</syntaxhighlight>

==={{header|MSX Basic}}===
<syntaxhighlight lang="qbasic">10 FOR I = 1 TO 10 STEP 0
20 PRINT "SPAM"
30 NEXT I</syntaxhighlight>
Also
<syntaxhighlight lang="qbasic">10 PRINT "SPAM"
20 GOTO 10</syntaxhighlight>


==={{header|QB64}}===
==={{header|QB64}}===
<lang QB64>'Using Do loop
<syntaxhighlight lang="qb64">'Using Do loop
Do 'Alternatively this could have a conditional, "Do While 1"
Do 'Alternatively this could have a conditional, "Do While 1"
Print "SPAM"
Print "SPAM"
Line 461: Line 491:
While 1
While 1
Print "SPAM"
Print "SPAM"
Wend</lang>
Wend</syntaxhighlight>


==={{header|Quite BASIC}}===
<syntaxhighlight lang="qbasic">10 print "SPAM"
20 goto 10</syntaxhighlight>

==={{Header|Tiny BASIC}}===
<syntaxhighlight lang="qbasic"> 10 PRINT "SPAM"
GOTO 10</syntaxhighlight>


==={{header|True BASIC}}===
==={{header|True BASIC}}===
<lang qbasic>DO
<syntaxhighlight lang="qbasic">DO
PRINT "SPAM"
PRINT "SPAM"
LOOP
LOOP
END</lang>
END</syntaxhighlight>


==={{header|Yabasic}}===
==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">do
<lang Yabasic>do
print "SPAM"
print "SPAM"
loop</lang>
loop</syntaxhighlight>


O también
O también
<lang Yabasic>while true
<syntaxhighlight lang="yabasic">while true
print "SPAM"
print "SPAM"
wend</lang>
wend</syntaxhighlight>


=={{header|Batch File}}==
=={{header|Batch File}}==
Using <code>goto</code>:
Using <code>goto</code>:
<lang dos>@echo off
<syntaxhighlight lang="dos">@echo off
:loop
:loop
echo SPAM
echo SPAM
goto loop</lang>
goto loop</syntaxhighlight>
Another variant which uses Windows NT's <code>for</code> statement:
Another variant which uses Windows NT's <code>for</code> statement:


{{works with|Windows NT|4 or later}}
{{works with|Windows NT|4 or later}}
<lang dos>for /l %%x in (1,0,2) do @echo SPAM</lang>
<syntaxhighlight lang="dos">for /l %%x in (1,0,2) do @echo SPAM</syntaxhighlight>
This essentially is a counted loop which starts at <code>1</code>, increments by <code>0</code> and stops when the counter reaches <code>2</code>.
This essentially is a counted loop which starts at <code>1</code>, increments by <code>0</code> and stops when the counter reaches <code>2</code>.


=={{header|BBC BASIC}}==
=={{header|BBC BASIC}}==
<lang bbcbasic> REPEAT
<syntaxhighlight lang="bbcbasic"> REPEAT
PRINT "SPAM"
PRINT "SPAM"
UNTIL FALSE</lang>
UNTIL FALSE</syntaxhighlight>


=={{header|bc}}==
=={{header|bc}}==
<lang bc>while (1) "SPAM
<syntaxhighlight lang="bc">while (1) "SPAM
"</lang>
"</syntaxhighlight>


=={{header|BCPL}}==
=={{header|BCPL}}==
<lang BCPL>get "libhdr"
<syntaxhighlight lang="bcpl">get "libhdr"


let start() be writes("SPAM*N") repeat</lang>
let start() be writes("SPAM*N") repeat</syntaxhighlight>


=={{header|beeswax}}==
=={{header|beeswax}}==
<lang beeswax>_>`SPA`p
<syntaxhighlight lang="beeswax">_>`SPA`p
bN`M`<</lang>
bN`M`<</syntaxhighlight>


=={{header|Befunge}}==
=={{header|Befunge}}==
Because the 2-D code space is toroidal, all loops are infinite
Because the 2-D code space is toroidal, all loops are infinite
unless explicitly stopped with '''@'''.
unless explicitly stopped with '''@'''.
<lang befunge>55+"MAPS",,,,,</lang>
<syntaxhighlight lang="befunge">55+"MAPS",,,,,</syntaxhighlight>

=={{header|Binary Lambda Calculus}}==
Adding "SPAM\n" to the BLC8 cycle program generated from https://github.com/tromp/AIT/blob/master/lists/cycle.lam
gives the 16 byte program
<pre>11 a1 72 34 00 2d e5 e7 ef b3 40 53 50 41 4d 0a</pre>


=={{header|blz}}==
=={{header|blz}}==
<lang blz>while true
<syntaxhighlight lang="blz">while true
print("SPAM")
print("SPAM")
end</lang>
end</syntaxhighlight>


=={{header|bootBASIC}}==
=={{header|bootBASIC}}==
Using <code>goto</code>:
Using <code>goto</code>:
<lang bootBASIC>10 print "SPAM"
<syntaxhighlight lang="bootbasic">10 print "SPAM"
20 goto 10</lang>
20 goto 10</syntaxhighlight>


Using <code>run</code>:
Using <code>run</code>:
<lang bootBASIC>10 print "SPAM"
<syntaxhighlight lang="bootbasic">10 print "SPAM"
20 run</lang>
20 run</syntaxhighlight>


=={{header|BQN}}==
=={{header|BQN}}==
Line 533: Line 575:
The main way of performing an infinite loop in BQN is using recursion.
The main way of performing an infinite loop in BQN is using recursion.


<lang BQN>{𝕊 •Out 𝕩}"SPAM"</lang>
<syntaxhighlight lang="bqn">{𝕊 •Out 𝕩}"SPAM"</syntaxhighlight>


will likely end in a stack overflow.
will likely end in a stack overflow.


=={{header|Bracmat}}==
=={{header|Bracmat}}==
<lang bracmat>whl'out$SPAM</lang>
<syntaxhighlight lang="bracmat">whl'out$SPAM</syntaxhighlight>


=={{header|Brainf***}}==
=={{header|Brainf***}}==
Optimized for code size:
Optimized for code size:
<lang bf>++++++++++[->++++++>++++++++>+<<<]>+++++>
<syntaxhighlight lang="bf">++++++++++[->++++++>++++++++>+<<<]>+++++>
[+++.---.<.>---.+++>.<]</lang>
[+++.---.<.>---.+++>.<]</syntaxhighlight>


Optimized for execution speed:
Optimized for execution speed:
<lang bf>10++++++++++
<syntaxhighlight lang="bf">10++++++++++
[-> 8++++++++ > 8++++++++ > 6++++++ > 8++++++++ > 1+ <<<<<]>
[-> 8++++++++ > 8++++++++ > 6++++++ > 8++++++++ > 1+ <<<<<]>
83+++ > 80 > 65+++++ > 77--- <<<
83+++ > 80 > 65+++++ > 77--- <<<
[.>.>.>.>.<<<<]</lang>
[.>.>.>.>.<<<<]</syntaxhighlight>


=={{header|Brat}}==
=={{header|Brat}}==
<lang brat>loop { p "SPAM" }</lang>
<syntaxhighlight lang="brat">loop { p "SPAM" }</syntaxhighlight>

=={{header|Bruijn}}==
<syntaxhighlight lang="bruijn">
:import std/String .

main [spam spam]
spam ["SPAM\n" ++ (0 0)]
</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==
<lang c>while(1) puts("SPAM");</lang>
<syntaxhighlight lang="c">while(1) puts("SPAM");</syntaxhighlight>
or
or
<lang c> for(;;) puts("SPAM");</lang>
<syntaxhighlight lang="c"> for(;;) puts("SPAM");</syntaxhighlight>
or
or
<lang c>do { puts("SPAM"); } while(1);</lang>
<syntaxhighlight lang="c">do { puts("SPAM"); } while(1);</syntaxhighlight>
or
or
<lang c>while(puts("SPAM"));</lang>
<syntaxhighlight lang="c">while(puts("SPAM"));</syntaxhighlight>
or
or
<syntaxhighlight lang="c">
<lang c>
spam: puts("SPAM");
spam: puts("SPAM");
goto spam;
goto spam;
</syntaxhighlight>
</lang>


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==


<lang csharp>while (true)
<syntaxhighlight lang="csharp">while (true)
{
{
Console.WriteLine("SPAM");
Console.WriteLine("SPAM");
}</lang>
}</syntaxhighlight>


=={{header|C++}}==
=={{header|C++}}==
{{trans|C}}
{{trans|C}}
<lang cpp>while (true)
<syntaxhighlight lang="cpp">while (true)
std::cout << "SPAM\n";</lang>
std::cout << "SPAM\n";</syntaxhighlight>
or
or
<lang cpp>for (;;)
<syntaxhighlight lang="cpp">for (;;)
std::cout << "SPAM\n";</lang>
std::cout << "SPAM\n";</syntaxhighlight>
or
or
<lang cpp>do
<syntaxhighlight lang="cpp">do
std::cout << "SPAM\n";
std::cout << "SPAM\n";
while (true);</lang>
while (true);</syntaxhighlight>

=={{header|C3}}==
<syntaxhighlight lang="c3">while(1) io::printn("SPAM");</syntaxhighlight>
or
<syntaxhighlight lang="c3">for(;;) io::printn("SPAM");</syntaxhighlight>
or
<syntaxhighlight lang="c3">do { io::printn("SPAM"); } while(1);</syntaxhighlight>
or
<syntaxhighlight lang="c3">switch (1)
{
case 1:
io::printn("SPAM");
nextcase 1;
}
</syntaxhighlight>


=={{header|Chapel}}==
=={{header|Chapel}}==
<lang chapel>while true do writeln("SPAM");</lang>
<syntaxhighlight lang="chapel">while true do writeln("SPAM");</syntaxhighlight>


=={{header|ChucK}}==
=={{header|ChucK}}==
<lang>
<syntaxhighlight lang="text">
while(true) <<<"SPAM">>>;
while(true) <<<"SPAM">>>;
</syntaxhighlight>
</lang>


=={{header|Clojure}}==
=={{header|Clojure}}==
<lang lisp>(loop [] (println "SPAM") (recur))</lang>
<syntaxhighlight lang="lisp">(loop [] (println "SPAM") (recur))</syntaxhighlight>


=={{header|COBOL}}==
=={{header|COBOL}}==
<lang cobol> IDENTIFICATION DIVISION.
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. Spam.
PROGRAM-ID. Spam.


Line 608: Line 673:


GOBACK
GOBACK
.</lang>
.</syntaxhighlight>
[[OpenCOBOL]] supports a <code>FOREVER</code> clause for <code>PERFORM</code> which will have the same effect.
[[OpenCOBOL]] supports a <code>FOREVER</code> clause for <code>PERFORM</code> which will have the same effect.


=={{header|CoffeeScript}}==
=={{header|CoffeeScript}}==
<lang coffeescript>loop
<syntaxhighlight lang="coffeescript">loop
console.log 'SPAM'
console.log 'SPAM'
</syntaxhighlight>
</lang>


=={{header|ColdFusion}}==
=={{header|ColdFusion}}==
Line 620: Line 685:


With tags:
With tags:
<lang cfm><cfloop condition = "true NEQ false">
<syntaxhighlight lang="cfm"><cfloop condition = "true NEQ false">
SPAM
SPAM
</cfloop></lang>
</cfloop></syntaxhighlight>
With script:
With script:
<lang cfm><cfscript>
<syntaxhighlight lang="cfm"><cfscript>
while( true != false )
while( true != false )
{
{
writeOutput( "SPAM" );
writeOutput( "SPAM" );
}
}
</cfscript></lang>
</cfscript></syntaxhighlight>


=={{header|Comal}}==
=={{header|Comal}}==
<lang Comal>LOOP
<syntaxhighlight lang="comal">LOOP
PRINT "SPAM"
PRINT "SPAM"
ENDLOOP</lang>
ENDLOOP</syntaxhighlight>


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
<lang lisp>(loop (write-line "SPAM"))</lang>
<syntaxhighlight lang="lisp">(loop (write-line "SPAM"))</syntaxhighlight>


=== Using DO ===
=== Using DO ===
<lang lisp>
<syntaxhighlight lang="lisp">
(do () ; Not initialization
(do () ; Not initialization
(nil) ; Not break condition
(nil) ; Not break condition
(print "SPAM")) ; On every loop as requested
(print "SPAM")) ; On every loop as requested
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 653: Line 718:


=={{header|Corescript}}==
=={{header|Corescript}}==
<syntaxhighlight lang="corescript">
<lang Corescript>
:top
:top
print Spam!
print Spam!
goto top
goto top
</syntaxhighlight>
</lang>


=={{header|Cowgol}}==
=={{header|Cowgol}}==
<lang cowgol>include "cowgol.coh";
<syntaxhighlight lang="cowgol">include "cowgol.coh";


loop
loop
print("Spam\n");
print("Spam\n");
end loop;</lang>
end loop;</syntaxhighlight>


=={{header|Crystal}}==
=={{header|Crystal}}==
<lang crystal>loop do
<syntaxhighlight lang="crystal">loop do
puts "SPAM"
puts "SPAM"
end</lang>
end</syntaxhighlight>


Using <code>while</code>/<code>until</code>:
Using <code>while</code>/<code>until</code>:
<lang crystal>while true
<syntaxhighlight lang="crystal">while true
puts "SPAM"
puts "SPAM"
end</lang>
end</syntaxhighlight>
<lang crystal>until false
<syntaxhighlight lang="crystal">until false
puts "SPAM"
puts "SPAM"
end</lang>
end</syntaxhighlight>


Using an infinite range:
Using an infinite range:
<lang crystal>(0..).each do
<syntaxhighlight lang="crystal">(0..).each do
puts "SPAM"
puts "SPAM"
end</lang>
end</syntaxhighlight>


=={{header|D}}==
=={{header|D}}==
Some common ways to create an infinite printing loop:
Some common ways to create an infinite printing loop:
<lang d>import std.stdio;
<syntaxhighlight lang="d">import std.stdio;


void main() {
void main() {
while (true)
while (true)
writeln("SPAM");
writeln("SPAM");
}</lang>
}</syntaxhighlight>


<lang d>import std.stdio;
<syntaxhighlight lang="d">import std.stdio;


void main() {
void main() {
Line 699: Line 764:
writeln("SPAM");
writeln("SPAM");
while (true);
while (true);
}</lang>
}</syntaxhighlight>


<lang d>import std.stdio;
<syntaxhighlight lang="d">import std.stdio;


void main() {
void main() {
for ( ; ; )
for ( ; ; )
writeln("SPAM");
writeln("SPAM");
}</lang>
}</syntaxhighlight>


<lang d>import std.stdio;
<syntaxhighlight lang="d">import std.stdio;


void main() {
void main() {
Line 714: Line 779:
writeln("SPAM");
writeln("SPAM");
goto LOOP;
goto LOOP;
}</lang>
}</syntaxhighlight>


=={{header|Dart}}==
=={{header|Dart}}==
<lang>
<syntaxhighlight lang="text">
main() {
main() {
while(true) {
while(true) {
Line 723: Line 788:
}
}
}
}
</syntaxhighlight>
</lang>


=={{header|dc}}==
=={{header|dc}}==
<lang dc>[[SPAM
<syntaxhighlight lang="dc">[[SPAM
]P dx]dx</lang>
]P dx]dx</syntaxhighlight>


This loop is a tail-recursive function.
This loop is a tail-recursive function.
Line 735: Line 800:


=={{header|DCL}}==
=={{header|DCL}}==
<lang DCL>$ loop:
<syntaxhighlight lang="dcl">$ loop:
$ write sys$output "SPAM"
$ write sys$output "SPAM"
$ goto loop</lang>
$ goto loop</syntaxhighlight>


=={{header|Delphi}}==
=={{header|Delphi}}==
''See [[#Pascal|Pascal]]''
''See [[#Pascal|Pascal]]''

=={{header|DIBOL-11}}==
<syntaxhighlight lang="DIBOL-11">
START ;Infinite Loop

RECORD SPAM
, A4, 'SPAM'

PROC
XCALL FLAGS (0007000000,1) ;Suppress STOP message

OPEN(8,O,'TT:')
LOOP,
WRITES(8,SPAM)
GOTO LOOP
END
</syntaxhighlight>

=={{header|Draco}}==
<syntaxhighlight lang="draco">proc nonrec main() void:
while true do
writeln("SPAM")
od
corp</syntaxhighlight>


=={{header|DWScript}}==
=={{header|DWScript}}==


<lang Delphi>while True do
<syntaxhighlight lang="delphi">while True do
PrintLn('SPAM');</lang>
PrintLn('SPAM');</syntaxhighlight>


=={{header|Dyalect}}==
=={{header|Dyalect}}==


<lang Dyalect>while true {
<syntaxhighlight lang="dyalect">while true {
print("SPAM")
print("SPAM")
}</lang>
}</syntaxhighlight>


=={{header|Déjà Vu}}==
=={{header|Déjà Vu}}==
<lang dejavu>while true:
<syntaxhighlight lang="dejavu">while true:
!print "SPAM"</lang>
!print "SPAM"</syntaxhighlight>
Infinite recursion thanks to tail calls:
Infinite recursion thanks to tail calls:
<lang dejavu>labda:
<syntaxhighlight lang="dejavu">labda:
!print "SPAM"
!print "SPAM"
recurse
recurse
call</lang>
call</syntaxhighlight>


=={{header|E}}==
=={{header|E}}==


<lang e>while (true) {
<syntaxhighlight lang="e">while (true) {
println("SPAM")
println("SPAM")
}</lang>
}</syntaxhighlight>


<lang e>def f() {
<syntaxhighlight lang="e">def f() {
println("SPAM")
println("SPAM")
f <- ()
f <- ()
}
}
f <- ()</lang>
f <- ()</syntaxhighlight>


The difference between these is that in the second,
The difference between these is that in the second,
other activities can be interleaved with the loop;
other activities can be interleaved with the loop;
in the first, no other processing will occur in this vat.
in the first, no other processing will occur in this vat.

=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">
while 1 = 1
print "SPAM"
.
</syntaxhighlight>


=={{header|EDSAC order code}}==
=={{header|EDSAC order code}}==
The EDSAC instruction set does not include an unconditional jump: it is necessary to synthesize it by using either an <code>E</code> "branch on accumulator sign bit clear" or <code>F</code> "branch on accumulator sign bit set" order, in circumstances where the condition is guaranteed to be met. For this specific task, guaranteeing it is trivial: printing characters does not change the contents of the accumulator at all. The solution presented here, however, is more general. We use a <code>T</code> "transfer and clear" order to store the accumulator's contents in storage address <i>θ</i>+17, then jump back to the beginning of the loop and reload the accumulator with an <code>A</code> "add" order. Note that the storage address used as a temporary variable should be set to zero on entry to the loop.
The EDSAC instruction set does not include an unconditional jump: it is necessary to synthesize it by using either an <code>E</code> "branch on accumulator sign bit clear" or <code>F</code> "branch on accumulator sign bit set" order, in circumstances where the condition is guaranteed to be met. For this specific task, guaranteeing it is trivial: printing characters does not change the contents of the accumulator at all. The solution presented here, however, is more general. We use a <code>T</code> "transfer and clear" order to store the accumulator's contents in storage address <i>θ</i>+17, then jump back to the beginning of the loop and reload the accumulator with an <code>A</code> "add" order. Note that the storage address used as a temporary variable should be set to zero on entry to the loop.
<lang edsac>[ Infinite loop
<syntaxhighlight lang="edsac">[ Infinite loop
=============
=============


Line 812: Line 908:
[ 17 ] PF
[ 17 ] PF


EZPF</lang>
EZPF</syntaxhighlight>


=={{header|Ela}}==
=={{header|Ela}}==
Line 818: Line 914:
===Direct Approach===
===Direct Approach===


<lang ela>open monad io
<syntaxhighlight lang="ela">open monad io


loop () = do
loop () = do
Line 824: Line 920:
loop ()
loop ()


loop () ::: IO</lang>
loop () ::: IO</syntaxhighlight>


===Non-strict version===
===Non-strict version===


<lang ela>open monad io
<syntaxhighlight lang="ela">open monad io


xs = "SPAM"::xs
xs = "SPAM"::xs
Line 837: Line 933:
takeit (num - 1) xs
takeit (num - 1) xs


_ = takeit 10 xs ::: IO</lang>
_ = takeit 10 xs ::: IO</syntaxhighlight>


=={{header|Elena}}==
=={{header|Elena}}==
ELENA 4.x:
ELENA 6.x:
<lang elena>public program()
<syntaxhighlight lang="elena">public program()
{
{
while (true)
while (true)
{
{
console.writeLine:"spam"
console.writeLine("spam")
}
}
}</lang>
}</syntaxhighlight>


=={{header|Elixir}}==
=={{header|Elixir}}==
<lang elixir>defmodule Loops do
<syntaxhighlight lang="elixir">defmodule Loops do
def infinite do
def infinite do
IO.puts "SPAM"
IO.puts "SPAM"
Line 857: Line 953:
end
end


Loops.infinite</lang>
Loops.infinite</syntaxhighlight>
or
or
<lang elixir>Stream.cycle(["SPAM"]) |> Enum.each(&IO.puts &1)</lang>
<syntaxhighlight lang="elixir">Stream.cycle(["SPAM"]) |> Enum.each(&IO.puts &1)</syntaxhighlight>


=={{header|Emacs Lisp}}==
=={{header|Emacs Lisp}}==
This is run in an external file.
<lang elisp>
#!/usr/bin/env emacs --script


<syntaxhighlight lang="lisp">(while t
(while (princ "SPAM\n"))
(message "SPAM"))</syntaxhighlight>
</lang>

=={{header|EMal}}==
<syntaxhighlight lang="emal">
for ever
writeLine("SPAM")
end
</syntaxhighlight>


=={{header|Erlang}}==
=={{header|Erlang}}==
<lang erlang>
<syntaxhighlight lang="erlang">
-module (main).
-module (main).
-export ([main/0]).
-export ([main/0]).
Line 877: Line 977:
io:fwrite( "SPAM~n" ),
io:fwrite( "SPAM~n" ),
main().
main().
</syntaxhighlight>
</lang>


=={{header|ERRE}}==
=={{header|ERRE}}==
<syntaxhighlight lang="erre">
<lang ERRE>
LOOP
LOOP
PRINT("SPAM")
PRINT("SPAM")
END LOOP
END LOOP
</syntaxhighlight>
</lang>
You can use also WHILE TRUE..END WHILE or REPEAT...UNTIL FALSE loops.
You can use also WHILE TRUE..END WHILE or REPEAT...UNTIL FALSE loops.


=={{header|Euphoria}}==
=={{header|Euphoria}}==
<syntaxhighlight lang="euphoria">
<lang Euphoria>
while 1 do
while 1 do
puts(1, "SPAM\n")
puts(1, "SPAM\n")
end while
end while
</syntaxhighlight>
</lang>


=={{header|F Sharp|F#}}==
=={{header|F Sharp|F#}}==
<lang fsharp>
<syntaxhighlight lang="fsharp">
// Imperative Solution
// Imperative Solution
while true do
while true do
Line 904: Line 1,004:
printfn "SPAM"
printfn "SPAM"
forever ()
forever ()
</syntaxhighlight>
</lang>


=={{header|Factor}}==
=={{header|Factor}}==
Tail recursion:
Tail recursion:
<lang factor>: spam ( -- ) "SPAM" print spam ;</lang>
<syntaxhighlight lang="factor">: spam ( -- ) "SPAM" print spam ;</syntaxhighlight>
Looping combinators:
Looping combinators:
<lang factor>[ "SPAM" print t ] loop</lang>
<syntaxhighlight lang="factor">[ "SPAM" print t ] loop</syntaxhighlight>
<lang factor>USE: combinators.extras
<syntaxhighlight lang="factor">USE: combinators.extras
[ "SPAM" print ] forever</lang>
[ "SPAM" print ] forever</syntaxhighlight>


=={{header|FALSE}}==
=={{header|FALSE}}==
<lang false>[1]["SPAM
<syntaxhighlight lang="false">[1]["SPAM
"]#</lang>
"]#</syntaxhighlight>


=={{header|Fantom}}==
=={{header|Fantom}}==


<lang fantom>
<syntaxhighlight lang="fantom">
class Main
class Main
{
{
Line 931: Line 1,031:
}
}
}
}
</syntaxhighlight>
</lang>


=={{header|Fermat}}==
=={{header|Fermat}}==
<lang fermat>while 1 do !!'SPAM'; od</lang>
<syntaxhighlight lang="fermat">while 1 do !!'SPAM'; od</syntaxhighlight>


=={{header|Fish}}==
=={{header|Fish}}==
<lang fish>a"MAPS"ooooo</lang>
<syntaxhighlight lang="fish">a"MAPS"ooooo</syntaxhighlight>


=={{header|Forth}}==
=={{header|Forth}}==
<lang forth>: email begin ." SPAM" cr again ;</lang>
<syntaxhighlight lang="forth">: email begin ." SPAM" cr again ;</syntaxhighlight>


=={{header|Fortran}}==
=={{header|Fortran}}==
FORTRAN 77
FORTRAN 77
<lang fortran>
<syntaxhighlight lang="fortran">
10 WRITE(*,*) 'SPAM'
10 WRITE(*,*) 'SPAM'
GO TO 10
GO TO 10
END
END
</syntaxhighlight>
</lang>


Fortran 90
Fortran 90
<lang fortran>
<syntaxhighlight lang="fortran">
program spam
program spam
implicit none
implicit none
Line 958: Line 1,058:
end do
end do
end program spam
end program spam
</syntaxhighlight>
</lang>


=={{header|Fortress}}==
=={{header|Fortress}}==
<lang fortress>
<syntaxhighlight lang="fortress">
component loops_infinite
component loops_infinite
export Executable
export Executable
Line 968: Line 1,068:
end
end
end
end
</syntaxhighlight>
</lang>


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>' FB 1.05.0
<syntaxhighlight lang="freebasic">' FB 1.05.0


Do
Do
Print "SPAM"
Print "SPAM"
Loop</lang>
Loop</syntaxhighlight>


=={{header|Frink}}==
=={{header|Frink}}==
<lang frink>
<syntaxhighlight lang="frink">
while true
while true
println["SPAM"]
println["SPAM"]
</syntaxhighlight>
</lang>


=={{header|FutureBasic}}==
=={{header|FutureBasic}}==
Loop de loop -- whose great idea was this?
Loop de loop -- whose great idea was this?
<lang futurebasic>
<syntaxhighlight lang="futurebasic">include "NSLog.incl"
include "ConsoleWindow"


dispatchglobal
while 1
while 1
print "Spam"
NSLog(@"SPAM")
wend
wend
</lang>
dispatchend

HandleEvents</syntaxhighlight>


=={{header|Gambas}}==
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/?gist=e63dcdc939f8a7dcfd3194d884f8d4a5 Click this link to run this code]'''
'''[https://gambas-playground.proko.eu/?gist=e63dcdc939f8a7dcfd3194d884f8d4a5 Click this link to run this code]'''
<lang gambas>Public Sub Main()
<syntaxhighlight lang="gambas">Public Sub Main()


Do
Do
Line 1,001: Line 1,103:
Loop
Loop


End</lang>
End</syntaxhighlight>


=={{header|GAP}}==
=={{header|GAP}}==
<lang gap>while true do
<syntaxhighlight lang="gap">while true do
Print("SPAM\n");
Print("SPAM\n");
od;</lang>
od;</syntaxhighlight>


=={{header|GB BASIC}}==
=={{header|GB BASIC}}==
<lang GB BASIC>10 print "SPAM"
<syntaxhighlight lang="gb basic">10 print "SPAM"
20 goto10</lang>
20 goto10</syntaxhighlight>

=={{header|GDScript}}==
{{works with|Godot|4.0.1}}

<syntaxhighlight lang="gdscript">
extends MainLoop


func _process(_delta: float) -> bool:
print("SPAM")
return false # _process loops until true is returned

</syntaxhighlight>


=={{header|GlovePIE}}==
=={{header|GlovePIE}}==
GlovePIE does not natively support multiple lines of output. As such, this code continuously changes the single line of output to SPAM. The below code does this without specifying an infinite loop because all GlovePIE scripts loop indefinitely until the program is stopped.
GlovePIE does not natively support multiple lines of output. As such, this code continuously changes the single line of output to SPAM. The below code does this without specifying an infinite loop because all GlovePIE scripts loop indefinitely until the program is stopped.
<lang GlovePIE>debug = "SPAM"</lang>
<syntaxhighlight lang="glovepie">debug = "SPAM"</syntaxhighlight>


=={{header|GML}}==
=={{header|GML}}==
<lang GML>while(1)
<syntaxhighlight lang="gml">while(1)
show_message("SPAM")</lang>
show_message("SPAM")</syntaxhighlight>


=={{header|Go}}==
=={{header|Go}}==
<lang go>package main
<syntaxhighlight lang="go">package main


import "fmt"
import "fmt"
Line 1,029: Line 1,144:
fmt.Printf("SPAM\n")
fmt.Printf("SPAM\n")
}
}
}</lang>
}</syntaxhighlight>


=={{header|Groovy}}==
=={{header|Groovy}}==
<lang groovy>while (true) {
<syntaxhighlight lang="groovy">while (true) {
println 'SPAM'
println 'SPAM'
}</lang>
}</syntaxhighlight>


=={{header|Halon}}==
=={{header|Halon}}==
<lang halon>forever {
<syntaxhighlight lang="halon">forever {
echo "SPAM";
echo "SPAM";
}</lang>
}</syntaxhighlight>
or (due to optimizations, these are equally fast)
or (due to optimizations, these are equally fast)
<lang halon>while (true) {
<syntaxhighlight lang="halon">while (true) {
echo "SPAM";
echo "SPAM";
}</lang>
}</syntaxhighlight>

=={{header|Hare}}==
<syntaxhighlight lang="hare">use fmt;

export fn main() void = {
for (true) {
fmt::println("SPAM")!;
};
};</syntaxhighlight>


=={{header|Haskell}}==
=={{header|Haskell}}==
<lang haskell>forever (putStrLn "SPAM")</lang>
<syntaxhighlight lang="haskell">forever (putStrLn "SPAM")</syntaxhighlight>
or
or
<lang haskell>import Control.Monad.Fix (fix)
<syntaxhighlight lang="haskell">import Control.Monad.Fix (fix)
fix (putStrLn "SPAM" >>) </lang>
fix (putStrLn "SPAM" >>) </syntaxhighlight>


=={{header|Haxe}}==
=={{header|Haxe}}==
<lang haxe>while (true)
<syntaxhighlight lang="haxe">while (true)
Sys.println("SPAM");</lang>
Sys.println("SPAM");</syntaxhighlight>


=={{header|hexiscript}}==
=={{header|hexiscript}}==
<lang hexiscript>while true; println "SPAM"; endwhile</lang>
<syntaxhighlight lang="hexiscript">while true; println "SPAM"; endwhile</syntaxhighlight>


=={{header|HicEst}}==
=={{header|HicEst}}==
<lang hicest>DO i = 1, 1E20 ! for i with 16 or more digits: i == i + 1 == loop infinite
<syntaxhighlight lang="hicest">DO i = 1, 1E20 ! for i with 16 or more digits: i == i + 1 == loop infinite
WRITE() "SPAM"
WRITE() "SPAM"
ENDDO</lang>
ENDDO</syntaxhighlight>


=={{header|HolyC}}==
=={{header|HolyC}}==
<lang holyc>while(1) Print("SPAM\n");</lang>
<syntaxhighlight lang="holyc">while(1) Print("SPAM\n");</syntaxhighlight>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==
There are several ways to write infinite loops in Icon. The most straightforward would be with repeat.
There are several ways to write infinite loops in Icon. The most straightforward would be with repeat.
<lang icon>procedure main()
<syntaxhighlight lang="icon">procedure main()
repeat write("SPAM")
repeat write("SPAM")
end</lang>
end</syntaxhighlight>


Alternately one could use one of these:
Alternately one could use one of these:
<lang icon>until &fail do write("SPAM") # always fails, needs succeed to break
<syntaxhighlight lang="icon">until &fail do write("SPAM") # always fails, needs succeed to break
...
...
while write("SPAM") # always succeeds, needs failure to break
while write("SPAM") # always succeeds, needs failure to break
Line 1,081: Line 1,205:
while write(|"SPAM") # this is a common mistake that results in an endless loop
while write(|"SPAM") # this is a common mistake that results in an endless loop
...
...
while write(1 to 5) # a clearer version of the same mistake that generates endless 1's</lang>
while write(1 to 5) # a clearer version of the same mistake that generates endless 1's</syntaxhighlight>


=={{header|IDL}}==
=={{header|IDL}}==
<lang IDL>while 1 do print,'SPAM'</lang>
<syntaxhighlight lang="idl">while 1 do print,'SPAM'</syntaxhighlight>


=={{header|Intercal}}==
=={{header|Intercal}}==
Assuming Turing Text I/O with 8-bit ASCII-compatible character set, using COME FROM:
Assuming Turing Text I/O with 8-bit ASCII-compatible character set, using COME FROM:


<lang intercal> NOTE THIS IS INTERCAL
<syntaxhighlight lang="intercal"> NOTE THIS IS INTERCAL
PLEASE ,1 <- #5
PLEASE ,1 <- #5
DO ,1 SUB #1 <- #54
DO ,1 SUB #1 <- #54
Line 1,099: Line 1,223:
DO READ OUT ,1
DO READ OUT ,1
(2) DO ,1 SUB #1 <- #134
(2) DO ,1 SUB #1 <- #134
(1) PLEASE ABSTAIN FROM (2)</lang>
(1) PLEASE ABSTAIN FROM (2)</syntaxhighlight>


=={{header|Io}}==
=={{header|Io}}==
<lang io>loop("SPAM" println)</lang>
<syntaxhighlight lang="io">loop("SPAM" println)</syntaxhighlight>


=={{header|J}}==
=={{header|J}}==


<lang j>(-[smoutput bind 'SPAM')^:_(1)</lang>
<syntaxhighlight lang="j"> ]F.(echo@'SPAM')0</syntaxhighlight>


Alternatively,
Alternatively,


<lang j>smoutput bind 'SPAM'^:1e99 ''</lang>
<syntaxhighlight lang="j">smoutput bind 'SPAM'^:1e99 ''</syntaxhighlight>


This second implementation relies on numeric inaccuracies in IEEE floating point notation.
This second implementation relies on numeric inaccuracies in IEEE floating point notation.
Line 1,117: Line 1,241:


=={{header|Java}}==
=={{header|Java}}==
<lang java>while (true) {
<syntaxhighlight lang="java">
System.out.println("SPAM");
while (true) System.out.print("SPAM\n");
</syntaxhighlight>
}</lang>


<lang java>for (;;) {
<syntaxhighlight lang="java">
System.out.println("SPAM");
for (;;) System.out.print("SPAM\n");
</syntaxhighlight>
}</lang>


=={{header|JavaScript}}==
=={{header|JavaScript}}==
<lang javascript>for (;;) console.log("SPAM");</lang>
<syntaxhighlight lang="javascript">for (;;) console.log("SPAM");</syntaxhighlight>
<lang javascript>while (true) console.log("SPAM");</lang>
<syntaxhighlight lang="javascript">while (true) console.log("SPAM");</syntaxhighlight>


=={{header|Joy}}==
=={{header|Joy}}==
<lang joy>DEFINE loop == [true []] dip while.
<syntaxhighlight lang="joy">DEFINE loop == [true []] dip while.
["SPAM\n" putchars] loop.</syntaxhighlight>

["SPAM\n" putchars] loop.</lang>


=={{header|jq}}==
=={{header|jq}}==
<lang jq>recurse("SPAM")</lang>
<syntaxhighlight lang="jq">recurse("SPAM")</syntaxhighlight>
{{Out}}
{{Out}}
"SPAM"
"SPAM"
Line 1,144: Line 1,267:


=={{header|Jsish}}==
=={{header|Jsish}}==
<lang javascript>for (;;) puts('SPAM');</lang>
<syntaxhighlight lang="javascript">for (;;) puts('SPAM');</syntaxhighlight>


=={{header|Julia}}==
=={{header|Julia}}==
<syntaxhighlight lang="julia">
<lang Julia>
while true
while true
println("SPAM")
println("SPAM")
end
end
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,165: Line 1,288:


=={{header|K}}==
=={{header|K}}==
<lang K> while[1; `0:"SPAM\n"]</lang>
<syntaxhighlight lang="k"> while[1; `0:"SPAM\n"]</syntaxhighlight>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
<lang scala>// version 1.0.6
<syntaxhighlight lang="scala">// version 1.0.6


fun main(args: Array<String>) {
fun main(args: Array<String>) {
while (true) println("SPAM")
while (true) println("SPAM")
}</lang>
}</syntaxhighlight>


=={{header|LabVIEW}}==
=={{header|LabVIEW}}==
Line 1,178: Line 1,301:


=={{header|Lambdatalk}}==
=={{header|Lambdatalk}}==
<lang scheme>
<syntaxhighlight lang="scheme">
{def loops_infinite
{def loops_infinite
{lambda {}
{lambda {}
Line 1,186: Line 1,309:
{loops_infinite}
{loops_infinite}
-> SPAM forever...
-> SPAM forever...
</syntaxhighlight>
</lang>

=={{header|Lang}}==
<syntaxhighlight lang="lang">
loop {
fn.println(SPAM)
}
</syntaxhighlight>


=={{header|Lang5}}==
=={{header|Lang5}}==
<lang lang5>do "SPAM\n" . loop</lang>
<syntaxhighlight lang="lang5">do "SPAM\n" . loop</syntaxhighlight>


=={{header|Lasso}}==
=={{header|Lasso}}==
<lang Lasso>// not wise to run this!
<syntaxhighlight lang="lasso">// not wise to run this!
while(1 > 0) => {^
while(1 > 0) => {^
'SPAM\r'
'SPAM\r'
^}</lang>
^}</syntaxhighlight>

=={{header|LDPL}}==
<syntaxhighlight lang="ldpl">procedure:
label spam
display "SPAM" lf
goto spam
</syntaxhighlight>


=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==
<CTRL><Break> is used to terminate such loops.
<CTRL><Break> is used to terminate such loops.
<syntaxhighlight lang="lb">
<lang lb>
while 1
while 1
print "SPAM"
print "SPAM"
wend
wend
end
end
</syntaxhighlight>
</lang>


=={{header|Lily}}==
=={{header|Lily}}==
<lang lily>
<syntaxhighlight lang="lily">
while 1: print("SPAM")
while 1: print("SPAM")
</syntaxhighlight>
</lang>


=={{header|Lingo}}==
=={{header|Lingo}}==
<lang lingo>repeat while TRUE
<syntaxhighlight lang="lingo">repeat while TRUE
put "SPAM"
put "SPAM"
end repeat</lang>
end repeat</syntaxhighlight>


=={{header|Lisaac}}==
=={{header|Lisaac}}==
Line 1,222: Line 1,359:


=={{header|LiveCode}}==
=={{header|LiveCode}}==
<lang LiveCode>repeat forever
<syntaxhighlight lang="livecode">repeat forever
put "SPAM" & return
put "SPAM" & return
end repeat</lang>
end repeat</syntaxhighlight>


=={{header|Logo}}==
=={{header|Logo}}==
<lang logo>forever [print "SPAM]</lang>
<syntaxhighlight lang="logo">forever [print "SPAM]</syntaxhighlight>


=={{header|LOLCODE}}==
=={{header|LOLCODE}}==
<lang lolcode>HAI
<syntaxhighlight lang="lolcode">HAI
CAN HAS STDIO?
CAN HAS STDIO?
IM IN YR LOOP
IM IN YR LOOP
VISIBLE "SPAM"
VISIBLE "SPAM"
IM OUTTA YR LOOP
IM OUTTA YR LOOP
KTHXBYE</lang>
KTHXBYE</syntaxhighlight>


=={{header|Lua}}==
=={{header|Lua}}==
<lang lua>
<syntaxhighlight lang="lua">
while true do
while true do
print("SPAM")
print("SPAM")
Line 1,247: Line 1,384:
print("SPAM")
print("SPAM")
until false
until false
</syntaxhighlight>
</lang>


=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
Line 1,253: Line 1,390:
If Esc works then Ctrl + Y (and other letters except C, A, Z, X, N, M. F, L), open Control form, which we can do: Next Step, Slow Flow, Stop, and we can show code,current stack, variables, or execute immediate statements. This works only in console, not in M2000 forms.
If Esc works then Ctrl + Y (and other letters except C, A, Z, X, N, M. F, L), open Control form, which we can do: Next Step, Slow Flow, Stop, and we can show code,current stack, variables, or execute immediate statements. This works only in console, not in M2000 forms.


<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckIt {
Module CheckIt {
Print "SPAM"
Print "SPAM"
Line 1,259: Line 1,396:
}
}
Checkit
Checkit
</syntaxhighlight>
</lang>
Using a Repeat (or Do) - Always block
Using a Repeat (or Do) - Always block
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckIt {
Module CheckIt {
Repeat {
Repeat {
Line 1,268: Line 1,405:
}
}
Checkit
Checkit
</syntaxhighlight>
</lang>


Printing text rendering using Report.
Printing text rendering using Report.
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckIt {
Module CheckIt {
\\ stop in every 2/3 of cosole lines
\\ stop in every 2/3 of cosole lines
Line 1,282: Line 1,419:
Report {SPAM
Report {SPAM
}
}
</syntaxhighlight>
</lang>


=={{header|M4}}==
=={{header|M4}}==
<lang M4>define(`spam',`SPAM
<syntaxhighlight lang="m4">define(`spam',`SPAM
spam')
spam')
spam</lang>
spam</syntaxhighlight>

=={{header|MACRO11}}==
<syntaxhighlight lang="MACRO11">
; Infinte Loop under RT11
.MCALL .PRINT
.EVEN
BEGIN:
LOOP:
.PRINT #SPAM
BR LOOP
SPAM: .ASCIZ /SPAM/
.END BEGIN
</syntaxhighlight>


=={{header|MAD}}==
<syntaxhighlight lang="mad"> VECTOR VALUES SPAM = $4HSPAM*$
LOOP PRINT FORMAT SPAM
TRANSFER TO LOOP
END OF PROGRAM</syntaxhighlight>


=={{header|Make}}==
=={{header|Make}}==
<lang make>spam:
<syntaxhighlight lang="make">spam:
@echo SPAM
@echo SPAM
$(MAKE)</lang>
$(MAKE)</syntaxhighlight>



=={{header|Malbolge}}==
=={{header|Malbolge}}==
<lang malbolge>
<syntaxhighlight lang="malbolge">
bP&A@?>=<;:9876543210/.-,+*)('&%$T"!~}|;]yxwvutslUSRQ.yx+i)J9edFb4`_^]\yxwRQ)(TSRQ]m!G0KJIyxFvDa%_@?"=<5:98765.-2+*/.-,+*)('&%$#"!~}|utyrqvutsrqjonmPkjihgfedc\DDYAA\>>Y;;V886L5322G//D,,G))>&&A##!7~5:{y7xvuu,10/.-,+*)('&%$#"yb}|{zyxwvutmVqSohmOOjihafeHcEa`YAA\[ZYRW:U7SLKP3NMLK-I,GFED&%%@?>=6;|9y70/4u210/o-n+k)"!gg$#"!x}`{zyxZvYtsrqSoRmlkjLhKfedcEaD_^]\>Z=XWVU7S6QPON0LKDI,GFEDCBA#?"=};438y6543s1r/o-&%*k('&%e#d!~}|^z]xwvuWsVqponPlOjihgIeHcba`B^A\[ZY;W:UTSR4PI2MLKJ,,AFE(&B;:?"~<}{zz165v3s+*/pn,mk)jh&ge#db~a_{^\xwvoXsrqpRnmfkjMKg`_GG\aDB^A?[><X;9U86R53ONM0KJC,+FEDC&A@?!!6||3876w4-tr*/.-&+*)('&%$e"!~}|utyxwvutWlkponmlOjchg`edGba`_XW\?ZYRQVOT7RQPINML/JIHAFEDC&A@?>!<;{98yw5.-ss*/pn,+lj(!~ff{"ca}`^z][wZXtWUqTRnQOkNLhgfIdcFaZ_^A\[Z<XW:U8SRQPOHML/JIHG*ED=%%:?>=~;:{876w43210/(-,+*)('h%$d"ca}|_z\rqYYnsVTpoRPledLLafIGcbE`BXW??TY<:V97S64P31M0.J-+G*(DCB%@?"=<;|98765.3210p.-n+$)i'h%${"!~}|{zyxwvuXVlkpSQmlOjLbafIGcbE`BXW??TY<:V97S64P31M0.J-+G*(D'%A@?"=<}:98y6543,1r/.o,+*)j'&%eez!~a|^tsx[YutWUqjinQOkjMhJ`_dGEaDB^A?[><X;9U86R53O20LKJ-HG*ED'BA@?>7~;:{y7x5.3210q.-n+*)jh&%$#"c~}`{z]rwvutWrkpohmPkjihafI^cba`_^A\[>YXW:UTS5QP3NM0KJ-HGF?D'BA:?>=~;:z8765v32s0/.-nl$#(ig%fd"ca}|_]yrqvYWsVTpSQmPNjMKgJHdGEa`_B]\?ZY<WVUTMR5PO20LK.IHA))>CB%#?87}}49zx6wu3tr0qo-nl*ki'hf$ec!~}`{^yxwvotsrUponQlkMihKIe^]EEZ_B@\?=Y<:V97S64P31M0.J-+GFE(C&A@?8=<;:{876w43s10qo-&%kk"'hf$ec!b`|_]y\ZvYWsVTpSQmlkNiLgf_dcba`C^]\?ZY;WV97SLK33HM0.J-+G*(D'%A$">!};|z8yw543t1r/(-,+*)(i&%fd"!~}|_t]xwvutslqTonmPkjLhKIeHFbEC_^A?[TSX;9UT7R4JIN1/K.,H+)E(&B%#?"~<}{987x/4ussr).o,+l)(h&ge#db~a_{^\x[YutWrTjinQOkNLhgJeG]\aDB^]@[=SRW:877LQP3N0FEJ-+**?DC&A#98=~|:98yx/4u21rp(',mk)(ig%|{"ca}`^z][wZXtWUqTRnQOkNLhKIedcFE`YB@@?ZYRW:UTS6QPO11F..CHGF)(CB;@#>!~;XzV7gwu-QrrqMoJIkZF'WC$#AbQ`_{^L9wI64"VDConzl+j);JJ%qGFEZ~}]{ygwRuc8aSq44"H1Y.iV,e*RQ
bP&A@?>=<;:9876543210/.-,+*)('&%$T"!~}|;]yxwvutslUSRQ.yx+i)J9edFb4`_^]\yxwRQ)(TSRQ]m!G0KJIyxFvDa%_@?"=<5:98765.-2+*/.-,+*)('&%$#"!~}|utyrqvutsrqjonmPkjihgfedc\DDYAA\>>Y;;V886L5322G//D,,G))>&&A##!7~5:{y7xvuu,10/.-,+*)('&%$#"yb}|{zyxwvutmVqSohmOOjihafeHcEa`YAA\[ZYRW:U7SLKP3NMLK-I,GFED&%%@?>=6;|9y70/4u210/o-n+k)"!gg$#"!x}`{zyxZvYtsrqSoRmlkjLhKfedcEaD_^]\>Z=XWVU7S6QPON0LKDI,GFEDCBA#?"=};438y6543s1r/o-&%*k('&%e#d!~}|^z]xwvuWsVqponPlOjihgIeHcba`B^A\[ZY;W:UTSR4PI2MLKJ,,AFE(&B;:?"~<}{zz165v3s+*/pn,mk)jh&ge#db~a_{^\xwvoXsrqpRnmfkjMKg`_GG\aDB^A?[><X;9U86R53ONM0KJC,+FEDC&A@?!!6||3876w4-tr*/.-&+*)('&%$e"!~}|utyxwvutWlkponmlOjchg`edGba`_XW\?ZYRQVOT7RQPINML/JIHAFEDC&A@?>!<;{98yw5.-ss*/pn,+lj(!~ff{"ca}`^z][wZXtWUqTRnQOkNLhgfIdcFaZ_^A\[Z<XW:U8SRQPOHML/JIHG*ED=%%:?>=~;:{876w43210/(-,+*)('h%$d"ca}|_z\rqYYnsVTpoRPledLLafIGcbE`BXW??TY<:V97S64P31M0.J-+G*(DCB%@?"=<;|98765.3210p.-n+$)i'h%${"!~}|{zyxwvuXVlkpSQmlOjLbafIGcbE`BXW??TY<:V97S64P31M0.J-+G*(D'%A@?"=<}:98y6543,1r/.o,+*)j'&%eez!~a|^tsx[YutWUqjinQOkjMhJ`_dGEaDB^A?[><X;9U86R53O20LKJ-HG*ED'BA@?>7~;:{y7x5.3210q.-n+*)jh&%$#"c~}`{z]rwvutWrkpohmPkjihafI^cba`_^A\[>YXW:UTS5QP3NM0KJ-HGF?D'BA:?>=~;:z8765v32s0/.-nl$#(ig%fd"ca}|_]yrqvYWsVTpSQmPNjMKgJHdGEa`_B]\?ZY<WVUTMR5PO20LK.IHA))>CB%#?87}}49zx6wu3tr0qo-nl*ki'hf$ec!~}`{^yxwvotsrUponQlkMihKIe^]EEZ_B@\?=Y<:V97S64P31M0.J-+GFE(C&A@?8=<;:{876w43s10qo-&%kk"'hf$ec!b`|_]y\ZvYWsVTpSQmlkNiLgf_dcba`C^]\?ZY;WV97SLK33HM0.J-+G*(D'%A$">!};|z8yw543t1r/(-,+*)(i&%fd"!~}|_t]xwvutslqTonmPkjLhKIeHFbEC_^A?[TSX;9UT7R4JIN1/K.,H+)E(&B%#?"~<}{987x/4ussr).o,+l)(h&ge#db~a_{^\x[YutWrTjinQOkNLhgJeG]\aDB^]@[=SRW:877LQP3N0FEJ-+**?DC&A#98=~|:98yx/4u21rp(',mk)(ig%|{"ca}`^z][wZXtWUqTRnQOkNLhKIedcFE`YB@@?ZYRW:UTS6QPO11F..CHGF)(CB;@#>!~;XzV7gwu-QrrqMoJIkZF'WC$#AbQ`_{^L9wI64"VDConzl+j);JJ%qGFEZ~}]{ygwRuc8aSq44"H1Y.iV,e*RQ
</syntaxhighlight>
</lang>


=={{header|Maple}}==
=={{header|Maple}}==
<syntaxhighlight lang="maple">
<lang Maple>
> do print(SPAM) end;
> do print(SPAM) end;
</syntaxhighlight>
</lang>


=={{header|Mathematica}} / {{header|Wolfram Language}}==
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<lang mathematica>While[True,
<syntaxhighlight lang="mathematica">While[True,
Print@"SPAM";
Print@"SPAM";
]</lang>
]</syntaxhighlight>


=={{header|MATLAB}} / {{header|Octave}}==
=={{header|MATLAB}} / {{header|Octave}}==
<lang Matlab>while true
<syntaxhighlight lang="matlab">while true
fprintf('SPAM\n')
fprintf('SPAM\n')
end</lang>
end</syntaxhighlight>


=={{header|Maxima}}==
=={{header|Maxima}}==
<lang maxima>do(disp("SPAM"));</lang>
<syntaxhighlight lang="maxima">do(disp("SPAM"));</syntaxhighlight>


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


=={{header|MelonBasic}}==
=={{header|MelonBasic}}==
Using <code>Goto:1</code>:
Using <code>Goto:1</code>:
<lang MelonBasic>Say:"SPAM"
<syntaxhighlight lang="melonbasic">Say:"SPAM"
Goto:1</lang>
Goto:1</syntaxhighlight>


Using <code>Goto:start</code>:
Using <code>Goto:start</code>:
<lang MelonBasic>Say:"SPAM"
<syntaxhighlight lang="melonbasic">Say:"SPAM"
Goto:start</lang>
Goto:start</syntaxhighlight>


=={{header|Metafont}}==
=={{header|Metafont}}==


<lang metafont>forever: message "SPAM"; endfor end</lang>
<syntaxhighlight lang="metafont">forever: message "SPAM"; endfor end</syntaxhighlight>


=={{header|Microsoft Small Basic}}==
=={{header|Microsoft Small Basic}}==
With <code>While</code>.
With <code>While</code>.
<lang microsoftsmallbasic>
<syntaxhighlight lang="microsoftsmallbasic">
While "True"
While "True"
TextWindow.WriteLine("SPAM")
TextWindow.WriteLine("SPAM")
EndWhile
EndWhile
</syntaxhighlight>
</lang>
With <code>Goto</code>.
With <code>Goto</code>.
<lang microsoftsmallbasic>
<syntaxhighlight lang="microsoftsmallbasic">
loopStart:
loopStart:
TextWindow.WriteLine("SPAM")
TextWindow.WriteLine("SPAM")
Goto loopStart
Goto loopStart
</syntaxhighlight>
</lang>


=={{header|min}}==
=={{header|min}}==
{{works with|min|0.19.3}}
{{works with|min|0.19.3}}
<lang min>(true) ("SPAM" puts!) while</lang>
<syntaxhighlight lang="min">(true) ("SPAM" puts!) while</syntaxhighlight>

=={{header|MIPS Assembly}}==
Thanks to [https://www.chibialiens.com/mips/ Chibialiens.com] for the header/footer, bitmap font, and print routines.
<syntaxhighlight lang="mips">.include "\SrcAll\Header.asm"
.include "\SrcAll\BasicMacros.asm"
.include "\SrcPSX\MemoryMap.asm"
.include "\SrcN64\MemoryMap.asm"
CursorX equ 0x100
CursorY equ 0x101
main:
la a0,MyString
jal PrintString
nop
jal NewLine
nop
j main
nop
MyString:
.byte "SPAM",255,0,0,0 ;the 3 zeroes are padding to ensure proper alignment.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MyFont:
.ifdef buildn64
.incbin "\ResN64\ChibiAkumas.fnt"
.endif
.ifdef buildPSX
.incbin "\ResPSX\ChibiAkumas.fnt"
.endif

.include "\SrcALL\graphics.asm"
.include "..\\SrcAll\monitor.asm"
.include "\SrcN64\Footer.asm"</syntaxhighlight>
{{out}}
[https://ibb.co/rpH9bVR Screenshot of Nintendo 64 emulator]


=={{header|МК-61/52}}==
=={{header|МК-61/52}}==
<lang>1 2 3 4 С/П БП 00</lang>
<syntaxhighlight lang="text">1 2 3 4 С/П БП 00</syntaxhighlight>


''Note'': because this device has no text output instead of "SPAM" was used the number (1234).
''Note'': because this device has no text output instead of "SPAM" was used the number (1234).


=={{header|Modula-2}}==
=={{header|Modula-2}}==
<lang modula2>LOOP
<syntaxhighlight lang="modula2">LOOP
InOut.WriteString ("SPAM");
InOut.WriteString ("SPAM");
InOut.WriteLn
InOut.WriteLn
END;</lang>
END;</syntaxhighlight>


=={{header|Modula-3}}==
=={{header|Modula-3}}==
<lang modula3>LOOP
<syntaxhighlight lang="modula3">LOOP
IO.Put("SPAM\n");
IO.Put("SPAM\n");
END;</lang>
END;</syntaxhighlight>


=={{header|Monte}}==
=={{header|Monte}}==


<syntaxhighlight lang="monte">
<lang Monte>
while (true):
while (true):
traceln("SPAM")
traceln("SPAM")
</syntaxhighlight>
</lang>


=={{header|MontiLang}}==
=={{header|MontiLang}}==
<lang MontiLang>WHILE TRUE
<syntaxhighlight lang="montilang">WHILE TRUE
|SPAM| PRINT .
|SPAM| PRINT .
ENDWHILE</lang>
ENDWHILE</syntaxhighlight>
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
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}}==
=={{header|MOO}}==
<lang moo>while (1)
<syntaxhighlight lang="moo">while (1)
player:tell("SPAM");
player:tell("SPAM");
endwhile</lang>
endwhile</syntaxhighlight>


=={{header|MUMPS}}==
=={{header|MUMPS}}==
<syntaxhighlight lang="mumps">
<lang MUMPS>
FOR WRITE "SPAM",!
FOR WRITE "SPAM",!
</syntaxhighlight>
</lang>


=={{header|Nanoquery}}==
=={{header|Nanoquery}}==
<lang Nanoquery>while true
<syntaxhighlight lang="nanoquery">while true
println "SPAM"
println "SPAM"
end</lang>
end</syntaxhighlight>


=={{header|Nemerle}}==
=={{header|Nemerle}}==
<lang Nemerle>while (true) WriteLine("SPAM");</lang>
<syntaxhighlight lang="nemerle">while (true) WriteLine("SPAM");</syntaxhighlight>
Or, using recursion:
Or, using recursion:
<lang Nemerle>def loop() : void
<syntaxhighlight lang="nemerle">def loop() : void
{
{
WriteLine("SPAM");
WriteLine("SPAM");
loop();
loop();
}</lang>
}</syntaxhighlight>


=={{header|NetRexx}}==
=={{header|NetRexx}}==
<lang NetRexx>/* NetRexx */
<syntaxhighlight lang="netrexx">/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
options replace format comments java crossref savelog symbols nobinary


Line 1,415: Line 1,609:
say 'SPAM'
say 'SPAM'
end spam
end spam
</syntaxhighlight>
</lang>


=={{header|NewLISP}}==
=={{header|NewLISP}}==
<lang NewLISP>(while (println "SPAM"))</lang>
<syntaxhighlight lang="newlisp">(while (println "SPAM"))</syntaxhighlight>


=={{header|Nim}}==
=={{header|Nim}}==
<lang nim>while true:
<syntaxhighlight lang="nim">while true:
echo "SPAM"</lang>
echo "SPAM"</syntaxhighlight>


=={{header|NS-HUBASIC}}==
=={{header|NS-HUBASIC}}==
Using <code>FOR</code>:
Using <code>FOR</code>:
<lang NS-HUBASIC>10 FOR I=0 TO 1 STEP 0
<syntaxhighlight lang="ns-hubasic">10 FOR I=0 TO 1 STEP 0
20 PRINT "SPAM"
20 PRINT "SPAM"
30 NEXT</lang>
30 NEXT</syntaxhighlight>


Using <code>GOTO</code>:
Using <code>GOTO</code>:
<lang NS-HUBASIC>10 PRINT "SPAM"
<syntaxhighlight lang="ns-hubasic">10 PRINT "SPAM"
20 GOTO 10</lang>
20 GOTO 10</syntaxhighlight>


Using <code>RUN</code>:
Using <code>RUN</code>:
<lang NS-HUBASIC>10 PRINT "SPAM"
<syntaxhighlight lang="ns-hubasic">10 PRINT "SPAM"
20 RUN</lang>
20 RUN</syntaxhighlight>

=={{header|Nu}}==
<syntaxhighlight lang="nu">
while true {print SPAM}
</syntaxhighlight>


=={{header|Oberon-2}}==
=={{header|Oberon-2}}==
<lang oberon2>
<syntaxhighlight lang="oberon2">
MODULE InfiniteLoop;
MODULE InfiniteLoop;
IMPORT
IMPORT
Line 1,448: Line 1,647:
END
END
END InfiniteLoop.
END InfiniteLoop.
</syntaxhighlight>
</lang>


=={{header|Objeck}}==
=={{header|Objeck}}==
<lang objeck>
<syntaxhighlight lang="objeck">
while(true) {
while(true) {
"SPAM"->PrintLine();
"SPAM"->PrintLine();
};
};
</syntaxhighlight>
</lang>


=={{header|OCaml}}==
=={{header|OCaml}}==
<lang ocaml>while true do
<syntaxhighlight lang="ocaml">while true do
print_endline "SPAM"
print_endline "SPAM"
done</lang>
done</syntaxhighlight>


or
or


<lang ocaml>let rec inf_loop() =
<syntaxhighlight lang="ocaml">let rec inf_loop() =
print_endline "SPAM";
print_endline "SPAM";
inf_loop()
inf_loop()
in
in
inf_loop()</lang>
inf_loop()</syntaxhighlight>


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.
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|Occam}}==
=={{header|Occam}}==
<lang occam>#USE "course.lib"
<syntaxhighlight lang="occam">#USE "course.lib"
PROC main (CHAN BYTE screen!)
PROC main (CHAN BYTE screen!)
WHILE TRUE
WHILE TRUE
out.string("SPAM*c*n", 0, screen)
out.string("SPAM*c*n", 0, screen)
:</lang>
:</syntaxhighlight>


=={{header|Octave}}==
=={{header|Octave}}==
<lang octave>while(1)
<syntaxhighlight lang="octave">while(1)
disp("SPAM")
disp("SPAM")
endwhile</lang>
endwhile</syntaxhighlight>


=={{header|Oforth}}==
=={{header|Oforth}}==


<lang Oforth>begin "SPAM" . again</lang>
<syntaxhighlight lang="oforth">begin "SPAM" . again</syntaxhighlight>


=={{header|Ol}}==
=={{header|Ol}}==
<lang scheme>
<syntaxhighlight lang="scheme">
(let loop ()
(let loop ()
(display "SPAM")
(display "SPAM")
(loop))
(loop))
</syntaxhighlight>
</lang>


=={{header|OPL}}==
=={{header|OPL}}==
<lang opl>PROC main:
<syntaxhighlight lang="opl">PROC main:
LOCAL loop%
LOCAL loop%
loop%=1
loop%=1
Line 1,502: Line 1,701:
PRINT "SPAM"
PRINT "SPAM"
ENDWH
ENDWH
ENDP</lang>
ENDP</syntaxhighlight>


=={{header|Oz}}==
=={{header|Oz}}==
<lang oz>for do
<syntaxhighlight lang="oz">for do
{Show 'SPAM'}
{Show 'SPAM'}
end</lang>
end</syntaxhighlight>


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
<lang parigp>while(1,
<syntaxhighlight lang="parigp">while(1,
print("SPAM")
print("SPAM")
);</lang>
);</syntaxhighlight>


For a shorter version, note that <code>print</code> returns <code>gnil</code> which is evaluated as <code>false</code>.
For a shorter version, note that <code>print</code> returns <code>gnil</code> which is evaluated as <code>false</code>.
A 'cheating' solution might use <code>print(SPAM)</code> on the hope that the variable SPAM is uninitialized and hence prints as the monomial in itself.
A 'cheating' solution might use <code>print(SPAM)</code> on the hope that the variable SPAM is uninitialized and hence prints as the monomial in itself.
But with the <code>'</code> operator that evaluation can be forced, regardless of the current value (if any) of that variable:
But with the <code>'</code> operator that evaluation can be forced, regardless of the current value (if any) of that variable:
<lang parigp>until(print('SPAM),)</lang>
<syntaxhighlight lang="parigp">until(print('SPAM),)</syntaxhighlight>


=={{header|Pascal}}==
=={{header|Pascal}}==
<lang pascal>while true do
<syntaxhighlight lang="pascal">while true do
writeln('SPAM');</lang>
writeln('SPAM');</syntaxhighlight>
Alternatively:
Alternatively:
<lang pascal>repeat
<syntaxhighlight lang="pascal">repeat
writeln('SPAM')
writeln('SPAM')
until false;</lang>
until false;</syntaxhighlight>


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>while(1){
<syntaxhighlight lang="perl">while(1){
print "SPAM\n";
print "SPAM\n";
}</lang>
}</syntaxhighlight>


or equivalently
or equivalently


<lang perl>print "SPAM\n" while 1;</lang>
<syntaxhighlight lang="perl">print "SPAM\n" while 1;</syntaxhighlight>


=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>-->
<!--<syntaxhighlight lang="phix">-->
<span style="color: #008080;">while</span> <span style="color: #004600;">true</span> <span style="color: #008080;">do</span>
<span style="color: #008080;">while</span> <span style="color: #004600;">true</span> <span style="color: #008080;">do</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"SPAM\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"SPAM\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<!--</lang>-->
<!--</syntaxhighlight>-->

=={{header|Phixmonti}}==
<syntaxhighlight lang="Phixmonti">/# Rosetta Code problem: https://rosettacode.org/w/index.php?title=Loops/Infinite
by Galileo, 11/2022 #/

true while "SPAM\n" print true endwhile</syntaxhighlight>


=={{header|PHP}}==
=={{header|PHP}}==
<lang php>while(1)
<syntaxhighlight lang="php">while(1)
echo "SPAM\n";</lang>
echo "SPAM\n";</syntaxhighlight>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>(loop (prinl "SPAM"))</lang>
<syntaxhighlight lang="picolisp">(loop (prinl "SPAM"))</syntaxhighlight>


=={{header|Pike}}==
=={{header|Pike}}==
<lang pike>
<syntaxhighlight lang="pike">
while(1)
while(1)
write("SPAM\n");
write("SPAM\n");
</syntaxhighlight>
</lang>


=={{header|PILOT}}==
=={{header|PILOT}}==
<lang pilot>*TypeSpam
<syntaxhighlight lang="pilot">*TypeSpam
type:SPAM
type:SPAM
jump:*TypeSpam</lang>
jump:*TypeSpam</syntaxhighlight>


=={{header|Pixilang}}==
=={{header|Pixilang}}==
<lang Pixilang>start:
<syntaxhighlight lang="pixilang">start:
fputs("SPAM\n")
fputs("SPAM\n")
go start</lang>
go start</syntaxhighlight>


=={{header|PL/I}}==
=={{header|PL/I}}==
<syntaxhighlight lang="pl/i">
<lang PL/I>
do forever;
do forever;
put list ('SPAM'); put skip;
put list ('SPAM'); put skip;
end;</lang>
end;</syntaxhighlight>

=={{header|PL/M}}==
<syntaxhighlight lang="PL/M">
100H:
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; CALL BDOS(0,0); END EXIT;
PRINT: PROCEDURE (S); DECLARE S ADDRESS; CALL BDOS(9,S); END PRINT;

DECLARE SPAM DATA ('SPAM',0DH,0AH,'$');

LOOP: DO;

CALL PRINT( .SPAM );
GO TO LOOP;

END;
EOF
</syntaxhighlight>


=={{header|Plain English}}==
=={{header|Plain English}}==
When <code>Repeat.</code> appears by itself, execution proceeds from the beginning of the routine. Normally you would include a conditional statement to break or exit when a condition is met, but not in this case.
When <code>Repeat.</code> appears by itself, execution proceeds from the beginning of the routine. Normally you would include a conditional statement to break or exit when a condition is met, but not in this case.
<lang plainenglish>To run:
<syntaxhighlight lang="plainenglish">To run:
Start up.
Start up.
Write SPAM forever.
Write SPAM forever.
Line 1,581: Line 1,804:
To write SPAM forever:
To write SPAM forever:
Write "SPAM" to the console.
Write "SPAM" to the console.
Repeat.</lang>
Repeat.</syntaxhighlight>


=={{header|plainTeX}}==
=={{header|plainTeX}}==
Compile in console mode, with, e.g. "pdftex <file name>".
Compile in console mode, with, e.g. "pdftex <file name>".
<lang tex>\newlinechar`\^^J
<syntaxhighlight lang="tex">\newlinechar`\^^J
\def\spam{\message{SPAM^^J}\spam}%
\def\spam{\message{SPAM^^J}\spam}%
\spam</lang>
\spam</syntaxhighlight>


=={{header|Pop11}}==
=={{header|Pop11}}==
<lang pop11>while true do
<syntaxhighlight lang="pop11">while true do
printf('SPAM', '%p\n');
printf('SPAM', '%p\n');
endwhile;</lang>
endwhile;</syntaxhighlight>


=={{header|PostScript}}==
=={{header|PostScript}}==
simple infinite loop:
simple infinite loop:
<lang postscript>{}loop</lang>
<syntaxhighlight lang="postscript">{}loop</syntaxhighlight>


A bit more complex infinite loop:
A bit more complex infinite loop:
<lang postscript>/go {
<syntaxhighlight lang="postscript">/go {
/spam
/spam
{ (SPAM\n) print flush }
{ (SPAM\n) print flush }
Line 1,609: Line 1,832:


%start spamming!
%start spamming!
go</lang>
go</syntaxhighlight>


=={{header|PowerShell}}==
=={{header|PowerShell}}==
<lang powershell>for () {
<syntaxhighlight lang="powershell">for () {
"SPAM"
"SPAM"
}</lang>
}</syntaxhighlight>


=={{header|Prolog}}==
=={{header|Prolog}}==
<lang prolog>repeat, write('SPAM'), nl, fail.</lang>
<syntaxhighlight lang="prolog">repeat, write('SPAM'), nl, fail.</syntaxhighlight>


=={{header|Pure Data}}==
=={{header|Pure Data}}==
Line 1,623: Line 1,846:
Screenshot: https://i.imgur.com/IrwaafZ.png
Screenshot: https://i.imgur.com/IrwaafZ.png


<lang Pure Data>#N canvas 426 88 450 300 10;
<syntaxhighlight lang="pure data">#N canvas 426 88 450 300 10;
#X obj 17 75 print;
#X obj 17 75 print;
#X msg 17 55 SPAM;
#X msg 17 55 SPAM;
Line 1,630: Line 1,853:
#X connect 1 0 0 0;
#X connect 1 0 0 0;
#X connect 2 0 1 0;
#X connect 2 0 1 0;
#X connect 3 0 2 0;</lang>
#X connect 3 0 2 0;</syntaxhighlight>


Notes: the loop is started by clicking the |1(, a [loadbang] could additionally be used. An [until] object, sent a bang, will loop forever, but will hang Pure Data, whereas a high-speed metro will function perfectly.
Notes: the loop is started by clicking the |1(, a [loadbang] could additionally be used. An [until] object, sent a bang, will loop forever, but will hang Pure Data, whereas a high-speed metro will function perfectly.
Line 1,636: Line 1,859:
=={{header|PureBasic}}==
=={{header|PureBasic}}==
===Repeat/Forever===
===Repeat/Forever===
<lang PureBasic>Repeat
<syntaxhighlight lang="purebasic">Repeat
PrintN("SPAM")
PrintN("SPAM")
ForEver</lang>
ForEver</syntaxhighlight>


===Goto===
===Goto===
<lang PureBasic>PrintIt:
<syntaxhighlight lang="purebasic">PrintIt:
PrintN("SPAM")
PrintN("SPAM")
Goto PrintIt</lang>
Goto PrintIt</syntaxhighlight>


=={{header|Python}}==
=={{header|Python}}==
In Python 2:
In Python 2:
<lang python>while 1:
<syntaxhighlight lang="python">while 1:
print "SPAM"</lang>
print "SPAM"</syntaxhighlight>


In python 3:
In python 3:
<lang python>while 1:
<syntaxhighlight lang="python">while 1:
print("SPAM")</lang>
print("SPAM")</syntaxhighlight>


Note: one can also use: "True" or any other non-false value.
Note: one can also use: "True" or any other non-false value.
Line 1,661: Line 1,884:
=={{header|Quackery}}==
=={{header|Quackery}}==


<lang Quackery>[ say "SPAM" cr again ]</lang>
<syntaxhighlight lang="quackery">[ say "SPAM" cr again ]</syntaxhighlight>


=={{header|R}}==
=={{header|R}}==
Line 1,667: Line 1,890:
To see this run either run in terminal mode, right click on the GUI window and deselect "Buffered Output" prior to execution, or add a call to flush.console() in the loop.
To see this run either run in terminal mode, right click on the GUI window and deselect "Buffered Output" prior to execution, or add a call to flush.console() in the loop.


<lang R>repeat print("SPAM")</lang>
<syntaxhighlight lang="r">repeat print("SPAM")</syntaxhighlight>


=={{header|Racket}}==
=={{header|Racket}}==


<lang racket>
<syntaxhighlight lang="racket">
#lang racket
#lang racket


Line 1,684: Line 1,907:
(for ([i (in-naturals)])
(for ([i (in-naturals)])
(displayln "SPAM"))
(displayln "SPAM"))
</syntaxhighlight>
</lang>


=={{header|Raku}}==
=={{header|Raku}}==
Line 1,690: Line 1,913:
{{works with|Rakudo Star|2010.08}}
{{works with|Rakudo Star|2010.08}}


<lang perl6>loop {
<syntaxhighlight lang="raku" line>loop {
say 'SPAM';
say 'SPAM';
}</lang>
}</syntaxhighlight>
In addition, there are various ways of writing lazy, infinite lists in Raku:
In addition, there are various ways of writing lazy, infinite lists in Raku:
<lang perl6>print "SPAM\n" xx *; # repetition operator
<syntaxhighlight lang="raku" line>print "SPAM\n" xx *; # repetition operator
print "SPAM\n", ~* ... *; # sequence operator
print "SPAM\n", ~* ... *; # sequence operator
map {say "SPAM"}, ^Inf; # upto operator</lang>
map {say "SPAM"}, ^Inf; # upto operator</syntaxhighlight>

=={{header|Rapira}}==
<syntaxhighlight lang="rapira">while 1 do
output: "SPAM"
od</syntaxhighlight>

=={{header|RATFOR}}==
<syntaxhighlight lang="RATFOR">
program loop

while (1==1)
write(*,101)"SPAM"
101 format(A)

end
</syntaxhighlight>


=={{header|REBOL}}==
=={{header|REBOL}}==
<lang REBOL>forever [print "SPAM"]</lang>
<syntaxhighlight lang="rebol">forever [print "SPAM"]</syntaxhighlight>


=={{header|Red}}==
=={{header|Red}}==
<lang Red>forever [
<syntaxhighlight lang="red">forever [
print "SPAM"
print "SPAM"
]</lang>
]</syntaxhighlight>


=={{header|ReScript}}==
=={{header|ReScript}}==
<lang ReScript>while true {
<syntaxhighlight lang="rescript">while true {
Js.log("SPAM")
Js.log("SPAM")
}</lang>
}</syntaxhighlight>


or
or


<lang ReScript>let rec inf_loop = () => {
<syntaxhighlight lang="rescript">let rec inf_loop = () => {
Js.log("SPAM")
Js.log("SPAM")
inf_loop()
inf_loop()
}</lang>
}</syntaxhighlight>


=={{header|Retro}}==
=={{header|Retro}}==
<lang Retro>[ "SPAM\n" puts -1 ] while</lang>
<syntaxhighlight lang="retro">[ "SPAM\n" puts -1 ] while</syntaxhighlight>


=={{header|REXX}}==
=={{header|REXX}}==
===simple===
===simple===
<lang rexx>/*REXX program displays the word SPAM forever. */
<syntaxhighlight lang="rexx">/*REXX program displays the word SPAM forever. */


do forever
do forever
Line 1,729: Line 1,968:
end /*DO forever*/
end /*DO forever*/
/*control will never reach here. */
/*control will never reach here. */
/*don't stick a fork in it. */</lang>
/*don't stick a fork in it. */</syntaxhighlight>


===esoteric===
===esoteric===
<lang rexx>/*REXX program displays the word SPAM forever. */
<syntaxhighlight lang="rexx">/*REXX program displays the word SPAM forever. */


do while 1==1 /*esoteric "forever" clause. */
do while 1==1 /*esoteric "forever" clause. */
Line 1,738: Line 1,977:
end /*DO while 1==1*/
end /*DO while 1==1*/
/*control will never reach here. */
/*control will never reach here. */
/*don't stick a fork in it. */</lang>
/*don't stick a fork in it. */</syntaxhighlight>


===GO TO version===
===GO TO version===
<lang rexx>/*REXX program displays the word SPAM forever. */
<syntaxhighlight lang="rexx">/*REXX program displays the word SPAM forever. */


tell_it: say 'SPAM'
tell_it: say 'SPAM'
Line 1,747: Line 1,986:


/*control will never reach here. */
/*control will never reach here. */
/*don't stick a fork in it. */</lang>
/*don't stick a fork in it. */</syntaxhighlight>
===too clever by half===
===too clever by half===
<lang rexx>/*REXX program displays the word SPAM forever. */
<syntaxhighlight lang="rexx">/*REXX program displays the word SPAM forever. */


do until 0>1 /*too-clever-by-half forever loop*/
do until 0>1 /*too-clever-by-half forever loop*/
Line 1,755: Line 1,994:
end /*DO until 0>1*/
end /*DO until 0>1*/
/*control will never reach here. */
/*control will never reach here. */
/*don't stick a fork in it. */</lang>
/*don't stick a fork in it. */</syntaxhighlight>


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<syntaxhighlight lang="ring">
while true
while true
see "Spam"
see "Spam"
end
end
</syntaxhighlight>
</lang>


=={{header|Robotic}}==
=={{header|Robotic}}==
This will display the word '''SPAM''' at the bottom of the screen indefinitely:
This will display the word '''SPAM''' at the bottom of the screen indefinitely:
<lang robotic>
<syntaxhighlight lang="robotic">
: "infinite_loop"
: "infinite_loop"
* "SPAM"
* "SPAM"
goto "infinite_loop"
goto "infinite_loop"
</syntaxhighlight>
</lang>

=={{header|RPL}}==
Usually in RPL, "printing" an object in RPL means putting it on top of the stack.
In the present case, the loop would not be infinite since sooner or later the stack will overflow.
But if the printer has an infinite paper roll, this will never stop:
≪ "SPAM" '''WHILE''' 1 '''REPEAT''' PR1 '''END''' ≫ EVAL


=={{header|Ruby}}==
=={{header|Ruby}}==
<lang ruby>loop {puts "SPAM"}
<syntaxhighlight lang="ruby">loop {puts "SPAM"}
</syntaxhighlight>
</lang>


=={{header|Run BASIC}}==
=={{header|Run BASIC}}==
<lang runbasic>[loop] print "Spam" :goto [loop]
<syntaxhighlight lang="runbasic">[loop] print "Spam" :goto [loop]


while 1
while 1
print "Spam"
print "Spam"
wend</lang>
wend</syntaxhighlight>


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>fn main() {
<syntaxhighlight lang="rust">fn main() {
loop {
loop {
println!("SPAM");
println!("SPAM");
}
}
}</lang>
}</syntaxhighlight>


=={{header|S-lang}}==
=={{header|S-lang}}==
<lang S-lang>forever print("SPAM");</lang>
<syntaxhighlight lang="s-lang">forever print("SPAM");</syntaxhighlight>


=={{header|Salmon}}==
=={{header|Salmon}}==
<lang Salmon>while (true)
<syntaxhighlight lang="salmon">while (true)
"SPAM"!;</lang>
"SPAM"!;</syntaxhighlight>


=={{header|Sather}}==
=={{header|Sather}}==
<lang sather>class MAIN is
<syntaxhighlight lang="sather">class MAIN is
main is
main is
loop
loop
Line 1,804: Line 2,049:
end;
end;
end;
end;
end;</lang>
end;</syntaxhighlight>


=={{header|Scala}}==
=={{header|Scala}}==
<lang scala>while (true)
<syntaxhighlight lang="scala">while (true)
println("SPAM")</lang>
println("SPAM")</syntaxhighlight>


=={{header|Scheme}}==
=={{header|Scheme}}==
<lang scheme>((lambda (x) (display "SPAM") (newline) (x x))
<syntaxhighlight lang="scheme">((lambda (x) (display "SPAM") (newline) (x x))
(lambda (x) (display "SPAM") (newline) (x x)))
(lambda (x) (display "SPAM") (newline) (x x)))
</syntaxhighlight>
</lang>


or, less Schemishly but with less redundancy:
or, less Schemishly but with less redundancy:


<lang scheme>(do () (#f) (display "SPAM") (newline))</lang>
<syntaxhighlight lang="scheme">(do () (#f) (display "SPAM") (newline))</syntaxhighlight>


=={{header|Scilab}}==
=={{header|Scilab}}==
{{works with|Scilab|5.5.1}}
{{works with|Scilab|5.5.1}}
<lang>while %T
<syntaxhighlight lang="text">while %T
printf("SPAM\n")
printf("SPAM\n")
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre>SPAM
<pre>SPAM
Line 1,832: Line 2,077:


=={{header|sed}}==
=={{header|sed}}==
<lang sed>:loop
<syntaxhighlight lang="sed">:loop
s/.*/SPAM/
s/.*/SPAM/
p
p
t loop</lang>
t loop</syntaxhighlight>
Sed requires at least one line of input to execute, so run as follows:
Sed requires at least one line of input to execute, so run as follows:
<pre>echo | sed ':loop;s/.*/SPAM/;p;t loop'</pre>
<pre>echo | sed ':loop;s/.*/SPAM/;p;t loop'</pre>


=={{header|Seed7}}==
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";


const proc: main is func
const proc: main is func
Line 1,847: Line 2,092:
writeln("SPAM");
writeln("SPAM");
end while;
end while;
end func;</lang>
end func;</syntaxhighlight>


=={{header|Self}}==
=={{header|Self}}==
<lang self>['SPAM' printLine] loop</lang>
<syntaxhighlight lang="self">['SPAM' printLine] loop</syntaxhighlight>


=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby>loop { say "SPAM!" };</lang>
<syntaxhighlight lang="ruby">loop { say "SPAM!" };</syntaxhighlight>


=={{header|Slate}}==
=={{header|Slate}}==
<lang slate>[inform: 'SPAM'] loop</lang>
<syntaxhighlight lang="slate">[inform: 'SPAM'] loop</syntaxhighlight>


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
<lang smalltalk>[
<syntaxhighlight lang="smalltalk">[
Transcript showCR:'boring stuff'.
Transcript showCR:'boring stuff'.
] loop
] loop
Line 1,873: Line 2,118:
[
[
Transcript showCR:'please press CTRL-c!'.
Transcript showCR:'please press CTRL-c!'.
] doWhile:[true]</lang>
] doWhile:[true]</syntaxhighlight>


=={{header|SNOBOL4}}==
=={{header|SNOBOL4}}==
<lang snobol>loop output = "SPAM" :(loop)
<syntaxhighlight lang="snobol">loop output = "SPAM" :(loop)
end</lang>
end</syntaxhighlight>


=={{header|SNUSP}}==
=={{header|SNUSP}}==
<lang snusp>@\>@\>@\>@\>++++++++++===!/ < < < < \
<syntaxhighlight lang="snusp">@\>@\>@\>@\>++++++++++===!/ < < < < \
| | | \M=@@@@+@+++++# \.>.>.>.>./
| | | \M=@@@@+@+++++# \.>.>.>.>./
| | \A=@@+@@@@+++#
| | \A=@@+@@@@+++#
| \P=@@+@@+@@+++#
| \P=@@+@@+@@+++#
\S=@@+@+@@@+++#</lang>
\S=@@+@+@@@+++#</syntaxhighlight>


=={{header|Sparkling}}==
=={{header|Sparkling}}==
<lang sparkling>while true {
<syntaxhighlight lang="sparkling">while true {
print("SPAM");
print("SPAM");
}</lang>
}</syntaxhighlight>


or
or


<lang sparkling>do {
<syntaxhighlight lang="sparkling">do {
print("SPAM");
print("SPAM");
} while true;</lang>
} while true;</syntaxhighlight>


or
or


<lang sparkling>for var b = true; b; b = true {
<syntaxhighlight lang="sparkling">for var b = true; b; b = true {
printf("SPAM\n");
printf("SPAM\n");
}</lang>
}</syntaxhighlight>


etc.
etc.
Line 1,910: Line 2,155:
{{works with|HomeSpun}}
{{works with|HomeSpun}}
{{works with|OpenSpin}}
{{works with|OpenSpin}}
<lang spin>con
<syntaxhighlight lang="spin">con
_clkmode = xtal1 + pll16x
_clkmode = xtal1 + pll16x
_clkfreq = 80_000_000
_clkfreq = 80_000_000
Line 1,925: Line 2,170:
waitcnt(_clkfreq + cnt)
waitcnt(_clkfreq + cnt)
ser.stop
ser.stop
cogstop(0)</lang>
cogstop(0)</syntaxhighlight>


=={{header|SPL}}==
=={{header|SPL}}==
<lang spl>>
<syntaxhighlight lang="spl">>
#.output("SPAM")
#.output("SPAM")
<</lang>
<</syntaxhighlight>


=={{header|SQL PL}}==
=={{header|SQL PL}}==
{{works with|Db2 LUW}} version 9.7 or higher.
{{works with|Db2 LUW}} version 9.7 or higher.
With SQL PL:
With SQL PL:
<lang sql pl>
<syntaxhighlight lang="sql pl">
--#SET TERMINATOR @
--#SET TERMINATOR @


Line 1,946: Line 2,191:
END WHILE;
END WHILE;
END @
END @
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 1,968: Line 2,213:


=={{header|Standard ML}}==
=={{header|Standard ML}}==
<lang sml>while true do
<syntaxhighlight lang="sml">while true do
print "SPAM\n";</lang>
print "SPAM\n";</syntaxhighlight>


or
or


<lang sml>let
<syntaxhighlight lang="sml">let
fun inf_loop () = (
fun inf_loop () = (
print "SPAM\n";
print "SPAM\n";
Line 1,980: Line 2,225:
in
in
inf_loop ()
inf_loop ()
end</lang>
end</syntaxhighlight>


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.
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.
Line 1,986: Line 2,231:
=={{header|Stata}}==
=={{header|Stata}}==


<lang stata>while 1 {
<syntaxhighlight lang="stata">while 1 {
display "SPAM"
display "SPAM"
}</lang>
}</syntaxhighlight>


=== Mata ===
=== Mata ===
<lang stata>while (1) printf("SPAM\n")</lang>
<syntaxhighlight lang="stata">while (1) printf("SPAM\n")</syntaxhighlight>


Also possible with a '''[https://www.stata.com/help.cgi?m2_for for]''' loop, but unlike C, the middle expression is not optional:
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>
<syntaxhighlight lang="stata">for (;1;) printf("SPAM\n")</syntaxhighlight>


=={{header|Swift}}==
=={{header|Swift}}==
<lang swift>while true {
<syntaxhighlight lang="swift">while true {
println("SPAM")
println("SPAM")
}</lang>
}</syntaxhighlight>


=={{header|SystemVerilog}}==
=={{header|SystemVerilog}}==


<lang SystemVerilog>program main;
<syntaxhighlight lang="systemverilog">program main;
initial forever $display("SPAM");
initial forever $display("SPAM");
endprogram
endprogram
</syntaxhighlight>
</lang>
=={{header|TailDot}}==

<syntaxhighlight lang="taildot">c,x,SPAM,v,x,j,3</syntaxhighlight>
=={{header|Tailspin}}==
=={{header|Tailspin}}==
<lang tailspin>
<syntaxhighlight lang="tailspin">
1 -> \(
'SPAM$#10;' -> \(
<> 'SPAM$#10;' -> !OUT::write
<> $ -> !OUT::write
1 -> #
$ -> #
\) -> !VOID
\) -> !VOID
</syntaxhighlight>
</lang>


=={{header|Tcl}}==
=={{header|Tcl}}==
<lang tcl>while true {
<syntaxhighlight lang="tcl">while true {
puts SPAM
puts SPAM
}
}
Line 2,024: Line 2,270:
for {} 1 {} {
for {} 1 {} {
puts SPAM
puts SPAM
}</lang>
}</syntaxhighlight>


=={{header|TI-83 BASIC}}==
=={{header|TI-83 BASIC}}==
Line 2,030: Line 2,276:
There are a few ways to achieve this in TI-83 BASIC
There are a few ways to achieve this in TI-83 BASIC


<lang ti83b>
<syntaxhighlight lang="ti83b">
:Lbl 1
:Lbl 1
:Disp "SPAM
:Disp "SPAM
:Goto 1
:Goto 1
</syntaxhighlight>
</lang>


Another way is by using a While loop
Another way is by using a While loop


<lang ti83b>
<syntaxhighlight lang="ti83b">
:While 1
:While 1
:Disp "SPAM
:Disp "SPAM
:End
:End
</syntaxhighlight>
</lang>


=={{header|TI-89 BASIC}}==
=={{header|TI-89 BASIC}}==


<lang ti89b>Loop
<syntaxhighlight lang="ti89b">Loop
Disp "SPAM"
Disp "SPAM"
EndLoop</lang>
EndLoop</syntaxhighlight>


=={{header|TorqueScript}}==
=={{header|TorqueScript}}==
<lang Torque>While(1)
<syntaxhighlight lang="torque">While(1)
echo("SPAM");</lang>
echo("SPAM");</syntaxhighlight>


=={{header|Transact-SQL}}==
=={{header|Transact-SQL}}==


<lang sql>WHILE 1=1 BEGIN
<syntaxhighlight lang="sql">WHILE 1=1 BEGIN
PRINT "SPAM"
PRINT "SPAM"
END</lang>
END</syntaxhighlight>


=={{header|Trith}}==
=={{header|Trith}}==
<lang trith>["SPAM" print] loop</lang>
<syntaxhighlight lang="trith">["SPAM" print] loop</syntaxhighlight>


=={{header|TUSCRIPT}}==
=={{header|TUSCRIPT}}==
TUSCRIPT has no infinite loop. 999999999 loops are the limit.
TUSCRIPT has no infinite loop. 999999999 loops are the limit.
<lang tuscript>
<syntaxhighlight lang="tuscript">
$$ MODE TUSCRIPT
$$ MODE TUSCRIPT
LOOP/999999999
LOOP/999999999
print "spam"
print "spam"
ENDLOOP
ENDLOOP
</syntaxhighlight>
</lang>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
Line 2,076: Line 2,322:


Use any of these loops:
Use any of these loops:
<lang bash>while :; do echo SPAM; done</lang>
<syntaxhighlight lang="bash">while :; do echo SPAM; done</syntaxhighlight>


<lang bash>while true; do echo "SPAM"; done</lang>
<syntaxhighlight lang="bash">while true; do echo "SPAM"; done</syntaxhighlight>


<lang bash>until false; do echo "SPAM"; done</lang>
<syntaxhighlight lang="bash">until false; do echo "SPAM"; done</syntaxhighlight>


{{works with|bash}}
{{works with|bash}}
Line 2,086: Line 2,332:
{{works with|zsh}}
{{works with|zsh}}


<lang bash>for ((;;)); do echo "SPAM"; done</lang>
<syntaxhighlight lang="bash">for ((;;)); do echo "SPAM"; done</syntaxhighlight>


==={{header|C Shell}}===
==={{header|C Shell}}===
<lang bash>while (1)
<syntaxhighlight lang="bash">while (1)
echo SPAM
echo SPAM
end</lang>
end</syntaxhighlight>


==={{header|es}}===
==={{header|es}}===
<lang es>forever {echo SPAM}</lang>
<syntaxhighlight lang="es">forever {echo SPAM}</syntaxhighlight>


=={{header|UnixPipes}}==
=={{header|UnixPipes}}==
<lang bash>yes SPAM</lang>
<syntaxhighlight lang="bash">yes SPAM</syntaxhighlight>


=={{header|Unlambda}}==
=={{header|Unlambda}}==
<lang unlambda> ``ci``s``s`kr``s``s``s``s`k.S`k.P`k.A`k.Mii</lang>
<syntaxhighlight lang="unlambda"> ``ci``s``s`kr``s``s``s``s`k.S`k.P`k.A`k.Mii</syntaxhighlight>


=={{header|Ursa}}==
=={{header|Ursa}}==
{{trans|Python}}
{{trans|Python}}
<lang ursa>while true
<syntaxhighlight lang="ursa">while true
out "SPAM" endl console
out "SPAM" endl console
end while</lang>
end while</syntaxhighlight>
=={{header|Uxntal}}==
<syntaxhighlight lang="Uxntal">
|0100
&l ;SPAM <print-str> !&l

@<print-str> ( str* -- )
&while ( -- )
LDAk #18 DEO
INC2 LDAk ?&while
POP2 JMP2r

@SPAM
"SPAM 0a $1</syntaxhighlight>


=={{header|V}}==
=={{header|V}}==
<lang v>true [
<syntaxhighlight lang="v">true [
'SPAM' puts
'SPAM' puts
] while</lang>
] while</syntaxhighlight>


=={{header|Vala}}==
=={{header|Vala}}==
<lang vala>for(;;) stdout.printf("SPAM\n");</lang>
<syntaxhighlight lang="vala">for(;;) stdout.printf("SPAM\n");</syntaxhighlight>
<lang vala>while(true) stdout.printf("SPAM\n");</lang>
<syntaxhighlight lang="vala">while(true) stdout.printf("SPAM\n");</syntaxhighlight>
<lang vala>do stdout.printf("SPAM\n"); while(true);</lang>
<syntaxhighlight lang="vala">do stdout.printf("SPAM\n"); while(true);</syntaxhighlight>

=={{header|Vale}}==
{{works with|Vale|0.2.0}}
<syntaxhighlight lang="vale">
import stdlib.*;

exported func main() {
while true {
println("SPAM");
}
}
</syntaxhighlight>


=={{header|VAX Assembly}}==
=={{header|VAX Assembly}}==
<lang VAX Assembly> 0000 0000 1 .entry main,0
<syntaxhighlight lang="vax assembly"> 0000 0000 1 .entry main,0
4D415053 8F DD 0002 2 pushl #^a"SPAM" ;string on stack
4D415053 8F DD 0002 2 pushl #^a"SPAM" ;string on stack
5E DD 0008 3 pushl sp ;reference to string
5E DD 0008 3 pushl sp ;reference to string
Line 2,128: Line 2,399:
F5 11 0015 8 brb loop ;forever
F5 11 0015 8 brb loop ;forever
0017 9
0017 9
0017 10 .end main</lang>
0017 10 .end main</syntaxhighlight>


=={{header|VBA}}==
=={{header|VBA}}==
<lang vb>Do
<syntaxhighlight lang="vb">Do
Debug.Print "SPAM"
Debug.Print "SPAM"
Loop</lang>
Loop</syntaxhighlight>


=={{header|VBScript}}==
=={{header|VBScript}}==
<lang vb>Do
<syntaxhighlight lang="vb">Do
WScript.Echo("SPAM")
WScript.Echo("SPAM")
Loop</lang>
Loop</syntaxhighlight>


=={{header|Vedit macro language}}==
=={{header|Vedit macro language}}==
<lang vedit>while (1) {
<syntaxhighlight lang="vedit">while (1) {
Message("Spam\n")
Message("Spam\n")
}</lang>
}</syntaxhighlight>
or:
or:
<lang vedit>do {
<syntaxhighlight lang="vedit">do {
Message("Spam\n")
Message("Spam\n")
} while (1)</lang>
} while (1)</syntaxhighlight>
or:
or:
<lang vedit>for (;1;) {
<syntaxhighlight lang="vedit">for (;1;) {
Message("Spam\n")
Message("Spam\n")
}</lang>
}</syntaxhighlight>
"Nearly infinite" loop can be done by using constant ALL (=1073741824) as repeat count:
"Nearly infinite" loop can be done by using constant ALL (=1073741824) as repeat count:
<lang vedit>Repeat (ALL) {
<syntaxhighlight lang="vedit">Repeat (ALL) {
Message("Spam\n")
Message("Spam\n")
}</lang>
}</syntaxhighlight>


=={{header|Visual Basic}}==
=={{header|Visual Basic}}==
<lang vb>Do
<syntaxhighlight lang="vb">Do
Debug.Print("SPAM")
Debug.Print("SPAM")
Loop</lang>
Loop</syntaxhighlight>


=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
'''Platform:''' [[.NET]]
'''Platform:''' [[.NET]]
{{works with|Visual Basic .NET|9.0+}}
{{works with|Visual Basic .NET|9.0+}}
<lang vbnet>Do
<syntaxhighlight lang="vbnet">Do
Console.WriteLine("SPAM")
Console.WriteLine("SPAM")
Loop</lang>
Loop</syntaxhighlight>

=={{header|V (Vlang)}}==
<syntaxhighlight lang="v (vlang)">fn main() {
for {
print("SPAM\n")
}
}</syntaxhighlight>


=={{header|Wart}}==
=={{header|Wart}}==
<lang wart>repeat :forever
<syntaxhighlight lang="wart">repeat :forever
prn "spam"</lang>
prn "spam"</syntaxhighlight>


=={{header|Wee Basic}}==
=={{header|Wee Basic}}==
<lang Wee Basic>let loop=1
<syntaxhighlight lang="wee basic">let loop=1
while loop=1
while loop=1
print 1 "SPAM"
print 1 "SPAM"
wend
wend
end</lang>
end</syntaxhighlight>




=={{header|Whenever}}==
=={{header|Whenever}}==
<lang whenever>
<syntaxhighlight lang="whenever">
1 print("SPAM");
1 print("SPAM");
1;
1;
</syntaxhighlight>
</lang>




=={{header|Wren}}==
=={{header|Wren}}==
<lang ecmascript>while (true) System.print("SPAM")</lang>
<syntaxhighlight lang="wren">while (true) System.print("SPAM")</syntaxhighlight>


=={{header|X86 Assembly}}==
=={{header|X86 Assembly}}==
{{works with|NASM|Linux}}
{{works with|NASM|Linux}}
<lang asm>
<syntaxhighlight lang="asm">
section .text
section .text
global _start
global _start
Line 2,208: Line 2,486:
msg db "SPAM",0xa
msg db "SPAM",0xa
len equ $-msg
len equ $-msg
</syntaxhighlight>
</lang>


=={{header|XLISP}}==
=={{header|XLISP}}==
It is of course possible to use a <code>WHILE</code> loop with a condition that will always evaluate to true:
It is of course possible to use a <code>WHILE</code> loop with a condition that will always evaluate to true:
<lang lisp>(defun keep-printing-spam ()
<syntaxhighlight lang="lisp">(defun keep-printing-spam ()
(while t
(while t
(display "SPAM")
(display "SPAM")
(newline) ) )</lang>
(newline) ) )</syntaxhighlight>
Although this idiom is very common (in many programming languages), however, it feels a bit like a misuse of a looping construct that is meant to be conditional. If an unconditional jump is really what we want, then that is what we have <tt>goto</tt> for; or rather, in XLISP we do not have <tt>goto</tt> (in so many words) but we can achieve the effect of it using tail recursion.
Although this idiom is very common (in many programming languages), however, it feels a bit like a misuse of a looping construct that is meant to be conditional. If an unconditional jump is really what we want, then that is what we have <tt>goto</tt> for; or rather, in XLISP we do not have <tt>goto</tt> (in so many words) but we can achieve the effect of it using tail recursion.
<lang lisp>(defun keep-printing-spam ()
<syntaxhighlight lang="lisp">(defun keep-printing-spam ()
(display "SPAM")
(display "SPAM")
(newline)
(newline)
(keep-printing-spam) )</lang>
(keep-printing-spam) )</syntaxhighlight>


=={{header|XPL0}}==
=={{header|XPL0}}==
<lang XPL0>code Text=12;
<syntaxhighlight lang="xpl0">code Text=12;
loop Text(0, "SPAM
loop Text(0, "SPAM
")</lang>
")</syntaxhighlight>


=={{header|Z80 Assembly}}==
=={{header|Z80 Assembly}}==
Line 2,231: Line 2,509:
Using the Amstrad CPC firmware:
Using the Amstrad CPC firmware:


<lang z80>org $4000
<syntaxhighlight lang="z80">org $4000


txt_output: equ $bb5a
txt_output: equ $bb5a
Line 2,244: Line 2,522:
jr print
jr print


spam: defm "SPAM\r\n\0"</lang>
spam: defm "SPAM\r\n\0"</syntaxhighlight>


=={{header|Zig}}==
=={{header|Zig}}==
<syntaxhighlight lang="zig">
<lang Zig>
const std = @import("std");
const std = @import("std");
pub fn main() !void {

const stdout_wr = std.io.getStdOut().writer();
pub fn main() void {
while (true)
while (true) try stdout_wr.writeAll("SPAM\n");
std.debug.print("SPAM\n", .{});
}
}
</syntaxhighlight>
</lang>
=={{header|zkl}}==
=={{header|zkl}}==
<lang zkl>while(1) { println("SPAM") }
<syntaxhighlight lang="zkl">while(1) { println("SPAM") }
while(True){ println("SPAM") }
while(True){ println("SPAM") }
foreach _ in ([0..]){ println("SPAM") }
foreach _ in ([0..]){ println("SPAM") }
[0..].pump(Console.println,T(Void,"SPAM"));
[0..].pump(Console.println,T(Void,"SPAM"));
[0..].pump(fcn{ println("SPAM") });
[0..].pump(fcn{ println("SPAM") });
fcn{ println("SPAM"); return(self.fcn()) }(); // tail recursive lambda</lang>
fcn{ println("SPAM"); return(self.fcn()) }(); // tail recursive lambda</syntaxhighlight>


{{omit from|GUISS}}
{{omit from|GUISS}}
Line 2,267: Line 2,544:
=={{header|Zoomscript}}==
=={{header|Zoomscript}}==
For typing:
For typing:
<lang Zoomscript>var loop
<syntaxhighlight lang="zoomscript">var loop
loop = 1
loop = 1
while ne loop 0
while ne loop 0
print "SPAM"
print "SPAM"
println
println
endwhile</lang>
endwhile</syntaxhighlight>
For importing:
For importing:



Latest revision as of 16:26, 17 March 2024

Task
Loops/Infinite
You are encouraged to solve this task according to the task description, using any language you may know.
Task

Print out       SPAM       followed by a   newline   in an infinite loop.


Related tasks



11l

L
   print(‘SPAM’)

360 Assembly

This for sure will result in a severe WTO buffer shortage.

INFINITE CSECT ,                       this PGM control section 
INFINITE AMODE 31                      addressing mode 31 bit 
INFINITE RMODE ANY                     loader can load either 24 or 31 
         BAKR  14,0                    stack caller's register contents
         LR    12,15                   establish base 
         LA    13,0                    no savearea 
         USING INFINITE,12             base to assembler 
         LA    10,1                    1 in reg 10 
         LA    11,2                    2 in reg 11 
LOOP     EQU   * 
         CR    10,11                   1==2? 
         BE    RETURN                  Yes, exit. 
        WTO    'SPAM',ROUTCDE=11       print SPAM to syslog 
         B     LOOP                    No, check again. 
RETURN   PR    ,                       return to caller
         END   INFINITE

4DOS Batch

@echo off
do forever 
  echo SPAM
enddo

6502 Assembly

Specific OS/hardware routines for printing are left unimplemented.

InfiniteLoop	LDX #0
PrintLoop:	LDA MSG,x
		JSR PrintAccumulator	;routine not implemented
		INX
		CPX #5
		BNE PrintLoop
		BEQ InfiniteLoop

MSG		.byte "SPAM", $0A

6800 Assembly

        .cr  6800
        .tf  spam6800.obj,AP1
        .lf  spam6800
;=====================================================;
;       Infinite SPAM loop for the Motorola 6800      ;
;                 by barrym 2013-04-10                ;
;-----------------------------------------------------;
; Prints the message "SPAM" repeatedly to an ascii    ;
;   terminal (console) connected to a 1970s vintage   ;
;   SWTPC 6800 system, which is the target device for ;
;   this assembly.                                    ;
; Many thanks to:                                     ;
;   swtpc.com for hosting Michael Holley's documents! ;
;   sbprojects.com for a very nice assembler!         ;
;   swtpcemu.com for a very capable emulator!         ;
; reg x is the string pointer                         ;
; reg a holds the ascii char to be output             ;
;-----------------------------------------------------;
outeee   =   $e1d1      ;ROM: console putchar routine
        .or  $0f00
;-----------------------------------------------------;
main    ldx  #string    ;Point to the string
        bra  puts       ;  and print it
outs    jsr  outeee     ;Emit a as ascii
        inx             ;Advance the string pointer
puts    ldaa ,x         ;Load a string character
        bne  outs       ;Print it if non-null
        bra  main       ;else restart
;=====================================================;
string  .as  "SPAM",#13,#10,#0
        .en

68000 Assembly

Hardware-specific routines for I/O are left unimplemented and just displayed as a subroutine, as this is not the focus of the task.

doSPAM:
LEA Message,A0
JSR PrintString
JMP doSPAM

Message:
DC.B "SPAM",13,10,0
EVEN

8086 Assembly

Works with: [DOSBox]

Loading Immediates

Spam:
mov ah,02h
mov dl,'S'  ;VASM replaces a character in single quotes with its ascii equivalent
int 21h     ;Print Char routine

mov dl,'P'
int 21h

mov dl, 'A'
int 21h

mov dl, 'M'
int 21h

mov dl,13  ;Carriage Return
int 21h

mov dl,10  ;New Line
int 21h

jmp Spam

Loading From A Data Source

mov ah, 02h                 ;prep int 21h for printing to screen
mov ax, seg SpamMessage     ;load into ax whatever segment the address of our message is in.
mov ds, ax                  ;segment registers on the original 8086 must be loaded from a register

cld                         ;clear the direction flag, this makes commands like "lodsb" auto-increment

SpamOuter:
mov si, offset SpamMessage  ;load the address of SpamMessage into the source index
SpamInner:
lodsb                       ;mov al,[ds:si] and increment si by 1.
cmp al,0                    ;is this the terminator?
jz SpamOuter                ;point si to the beginning of the message again
mov dl,al                   ;the DOS interrupt for printing requires the desired character to be in DL
int 21h                     ;print the chosen character to the screen
jmp SpamInner

SpamMessage db "SPAM",13,10,0

8th

One way:

: inf "SPAM\n" . recurse ;

Another way:

: inf repeat "SPAM\n" . again ;

AArch64 Assembly

Works with: as version Raspberry Pi 3B version Buster 64 bits
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program infinite64.s   */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
/*********************************/
/* Initialized data              */
/*********************************/
.data
szMessage:           .asciz "SPAM\n"
/*********************************/
/*  code section                 */
/*********************************/
.text
.global main
 
main:
 
loop:
    ldr x0,qAdrszMessage
    bl affichageMess
    b loop

qAdrszMessage:     .quad szMessage

/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"

ACL2

(defun spam ()
   (declare (xargs :mode :program))
   (if nil
       nil
       (prog2$ (cw "SPAM~%")
               (spam))))

Action!

PROC Main()
  DO
    PrintE("SPAM")
  OD
RETURN
Output:

Screenshot from Atari 8-bit computer

SPAM
SPAM
SPAM
SPAM
SPAM
SPAM
SPAM
SPAM
SPAM
SPAM
SPAM
SPAM
...

ActionScript

while (true) {
    trace("SPAM");
}

Ada

loop
   Put_Line("SPAM");
end loop;

Agena

Tested with Agena 2.9.5 Win32

do
    print( "SPAM" )
od

Aime

while (1) {
    o_text("SPAM\n");
}

ALGOL 60

Translation of: ALGOL W


Based on the 1962 Revised Repport on ALGOL:

 begin
   integer i;
   for i:=1 step 0 until 2 do 
     outtext("spam")
 end
Works with: ALGOL 60 version OS/360
'BEGIN' 'COMMENT' Loops/Infinite - Algol60 - 23/06/2018;
  'INTEGER' I;
  'FOR' I := 1 'STEP' 0 'UNTIL' 2 'DO' 
    OUTSTRING(1,'('SPAM')')
'END'

ALGOL 68

DO
  printf($"SPAM"l$)
OD

Or the classic "dynamic halt":

loop x:
   printf($"SPAM"l$);
loop x

ALGOL W

begin
    for i := 1 step 0 until 2 do write( "SPAM" )
end.

AmigaE

PROC main()
  LOOP
    WriteF('SPAM')
  ENDLOOP
ENDPROC

AppleScript

repeat
  log "SPAM"
end repeat

ARM Assembly

.global main

main:

loop:
    ldr r0, =message
    bl printf
    b loop

message:
    .asciz "SPAM\n"

ArnoldC

IT'S SHOWTIME
STICK AROUND @NO PROBLEMO
TALK TO THE HAND "SPAM"
CHILL
YOU HAVE BEEN TERMINATED

Arturo

while [true] [
	print "SPAM"
]

AutoHotkey

Loop
  MsgBox SPAM `n

AWK

BEGIN {
  while(1) {
    print "SPAM"
  }
}

Axe

Warning: running this program will cause you to need to reset your calculator, thereby losing any user data stored in RAM.

While 1
 Disp "SPAM",i
End

BASIC

Works with: QuickBasic version 4.5

Old-fashioned syntax:

while 1
  print "SPAM"
wend

Standard BASIC:

do
  print "SPAM"
loop

Also

for i = 1 to 10 step 0
  print "SPAM"
next i
Works with: Applesoft BASIC
Works with: Commodore BASIC
Works with: Tiny BASIC
Works with: ZX Spectrum Basic

The most intuitive method is to use the GOTO statement.

10 print "SPAM"
20 goto 10

Generally, using GOSUB in place of GOTO is incorrect. Some programming bugs come about when a GOSUB causes a potentially infinite loop, however, eventually stack memory will fill up and cause a terminating error as shown in this Commodore BASIC example:

ready.
new

ready.
10 print "spam! ";:gosub 10
run
spam! spam! spam! spam! spam! spam! spam
! spam! spam! spam! spam! spam! spam! sp
am! spam! spam! spam! spam! spam! spam!
spam! spam! spam! spam! spam! spam!
?out of memory  error in 10
ready.
█

The solution is to keep the stack empty, however, this will also clear all variables used and prevent the use of RETURNing from the "subroutine". This is accomplished with the CLEAR (or CLR in Commodore BASIC) placed at the start of the loop.

10 clr:print "Commodore Spam! ";:gosub 10
10 clear : print "Apple Spam! ";: gosub 10

Rather than a GOTO, instead we can use a FOR... NEXT statement:

10 for i = 1 to 10 step 0 : rem A zero step makes the loop infinite
20 print "SPAM";
30 next i

In most cases, we can also call the RUN command from within the program.

10 print "Spam! ";
20 run

IF... THEN has an implied GOTO on some BASICs...

10 print "SPAM SPAM! ";:if 1 then 10

Applesoft BASIC

FOR I = 0 TO 1 STEP 0 : PRINT "SPAM" : NEXT


BASIC256

while true
    print "SPAM"
end while

Chipmunk Basic

Works with: Chipmunk Basic version 3.6.4
10 while 1
20  print "SPAM"
30 wend

Commodore BASIC

In addition to the general examples listed above for BASIC, there is a trick to get a Commodore BASIC program to endlessly loop its listing. All of the lines of code are a linked list in RAM. The trick is accomplished by modifying the pointer to the next line, which is recorded at the very start of each tokenized BASIC line. Instead of it pointing to the next line, you can make it point to a previous line, or itself. This will affect execution when any GOTO or GOSUB needs to reference any line number after the affected line, since the line search will be corrupted (and endless...)

For example, on the Commodore 64, BASIC program storage begins at $0800 (2048) with a NULL byte, the first line begins at $0801 with the little-endian pointer to the memory address that begins the next line. After entering the short program, POKE a 1 into the low byte portion of the pointer (location $0801) causing complete pointer value to be $0801... pointing to itself. Then run or list the program for endless looping fun.

Other similarly structured BASICs based on the early Microsoft BASIC (where the LIST routine follows the linked list pointers) can be manipulated in the same manner if it is known where BASIC program memory starts.

ready.
10 rem there is way too much spam in this program!
20 print "spam!!";:goto 10
poke 2049,1

ready.
run
spam!!spam!!spam!!spam!!spam!!spam!!spam!!spam!!
spam!!spam!!spam!!spam!!spam!!spam!!spam!!spam!!
spam!!spam!!spam!!spam!!spam!!spam!!spam!!spam!!
spam!!spam!!spam!!spam!!spam!!spam!!spam!!spam!!
spam!!spam!!spam!!spam!!spam!!spam!!spam!!spam!!
break in 10
ready.
list

10 rem there is way too much spam in this program!
10 rem there is way too much spam in this program!
10 rem there is way too much spam in this program!
10 rem there is way too much spam in this program!
10 rem there is way too much spam in this program!
10 rem there is way too much spam in this program!
break
ready.
█

Craft Basic

do
	print "SPAM"
loop

GW-BASIC

Works with: PC-BASIC
10 WHILE 1
20  PRINT "SPAM"
30 WEND

Also

10 PRINT "SPAM"
20 GOTO 10

IS-BASIC

100 DO
110   PRINT "SPAM"
120 LOOP

MSX Basic

10 FOR I = 1 TO 10 STEP 0
20  PRINT "SPAM"
30 NEXT I

Also

10 PRINT "SPAM"
20 GOTO 10

QB64

'Using Do loop
Do                'Alternatively this could have a conditional, "Do While 1"
     Print "SPAM"
Loop

'Using While loop
While 1
     Print "SPAM"
Wend

Quite BASIC

10 print "SPAM"
20 goto 10

Tiny BASIC

 10 PRINT "SPAM"
	GOTO 10

True BASIC

DO
   PRINT "SPAM"
LOOP
END

Yabasic

do
  print "SPAM"
loop

O también

while true
  print "SPAM"
wend

Batch File

Using goto:

@echo off
:loop
echo SPAM
goto loop

Another variant which uses Windows NT's for statement:

Works with: Windows NT version 4 or later
for /l %%x in (1,0,2) do @echo SPAM

This essentially is a counted loop which starts at 1, increments by 0 and stops when the counter reaches 2.

BBC BASIC

      REPEAT
        PRINT "SPAM"
      UNTIL FALSE

bc

while (1) "SPAM
"

BCPL

get "libhdr"

let start() be writes("SPAM*N") repeat

beeswax

_>`SPA`p
  bN`M`<

Befunge

Because the 2-D code space is toroidal, all loops are infinite unless explicitly stopped with @.

55+"MAPS",,,,,

Binary Lambda Calculus

Adding "SPAM\n" to the BLC8 cycle program generated from https://github.com/tromp/AIT/blob/master/lists/cycle.lam gives the 16 byte program

11 a1 72 34 00 2d e5 e7 ef b3 40 53 50 41 4d 0a

blz

while true
    print("SPAM")
end

bootBASIC

Using goto:

10 print "SPAM"
20 goto 10

Using run:

10 print "SPAM"
20 run

BQN

The main way of performing an infinite loop in BQN is using recursion.

{𝕊 •Out 𝕩}"SPAM"

will likely end in a stack overflow.

Bracmat

whl'out$SPAM

Brainf***

Optimized for code size:

++++++++++[->++++++>++++++++>+<<<]>+++++>
[+++.---.<.>---.+++>.<]

Optimized for execution speed:

10++++++++++
[-> 8++++++++ > 8++++++++ > 6++++++ > 8++++++++ > 1+ <<<<<]>
83+++ > 80 > 65+++++ > 77--- <<<
[.>.>.>.>.<<<<]

Brat

loop { p "SPAM" }

Bruijn

:import std/String .

main [spam spam]
	spam ["SPAM\n" ++ (0 0)]

C

while(1) puts("SPAM");

or

 for(;;) puts("SPAM");

or

do { puts("SPAM"); } while(1);

or

while(puts("SPAM"));

or

spam: puts("SPAM");
goto spam;

C#

while (true)
{
    Console.WriteLine("SPAM");
}

C++

Translation of: C
while (true)
  std::cout << "SPAM\n";

or

for (;;)
  std::cout << "SPAM\n";

or

do
  std::cout << "SPAM\n";
while (true);

C3

while(1) io::printn("SPAM");

or

for(;;) io::printn("SPAM");

or

do { io::printn("SPAM"); } while(1);

or

switch (1)
{
  case 1:
    io::printn("SPAM");
    nextcase 1;
}

Chapel

while true do writeln("SPAM");

ChucK

while(true) <<<"SPAM">>>;

Clojure

(loop [] (println "SPAM") (recur))

COBOL

       IDENTIFICATION DIVISION.
       PROGRAM-ID. Spam.

       PROCEDURE DIVISION.
           PERFORM UNTIL 1 <> 1
               DISPLAY "SPAM"
           END-PERFORM

           GOBACK
           .

OpenCOBOL supports a FOREVER clause for PERFORM which will have the same effect.

CoffeeScript

loop
  console.log 'SPAM'

ColdFusion

This will result in a JRun Servlet Error and heap dump.

With tags:

<cfloop condition = "true NEQ false">
  SPAM
</cfloop>

With script:

<cfscript>
  while( true != false )
  {
    writeOutput( "SPAM" );
  }
</cfscript>

Comal

LOOP
   PRINT "SPAM"
ENDLOOP

Common Lisp

(loop (write-line "SPAM"))

Using DO

(do ()					; Not initialization
    (nil)				; Not break condition
  (print "SPAM"))			; On every loop as requested
Output:
"SPAM"
...

Corescript

:top
print Spam!
goto top

Cowgol

include "cowgol.coh";

loop
    print("Spam\n");
end loop;

Crystal

loop do
    puts "SPAM"
end

Using while/until:

while true
    puts "SPAM"
end
until false
    puts "SPAM"
end

Using an infinite range:

(0..).each do
    puts "SPAM"
end

D

Some common ways to create an infinite printing loop:

import std.stdio;

void main() {
    while (true)
        writeln("SPAM");
}
import std.stdio;

void main() {
    do
        writeln("SPAM");
    while (true);
}
import std.stdio;

void main() {
    for ( ; ; )
        writeln("SPAM");
}
import std.stdio;

void main() {
    LOOP:
    writeln("SPAM");
    goto LOOP;
}

Dart

main() {
  while(true) {
    print("SPAM");
  }
}

dc

[[SPAM
]P dx]dx

This loop is a tail-recursive function. The program pushes the function on the stack, the outer dx makes the first call, and the inner dx makes each recursive call.

DCL

$ loop:
$  write sys$output "SPAM"
$  goto loop

Delphi

See Pascal

DIBOL-11

          START     ;Infinite Loop 

          RECORD  SPAM
,         A4, 'SPAM'

          PROC
          XCALL FLAGS (0007000000,1)          ;Suppress STOP message

          OPEN(8,O,'TT:')
LOOP,
          WRITES(8,SPAM)
          GOTO LOOP
          END

Draco

proc nonrec main() void:
    while true do
        writeln("SPAM")
    od
corp

DWScript

while True do
   PrintLn('SPAM');

Dyalect

while true {
    print("SPAM")
}

Déjà Vu

while true:
	!print "SPAM"

Infinite recursion thanks to tail calls:

labda:
	!print "SPAM"
	recurse
call

E

while (true) {
    println("SPAM")
}
def f() {
    println("SPAM")
    f <- ()
}
f <- ()

The difference between these is that in the second, other activities can be interleaved with the loop; in the first, no other processing will occur in this vat.

EasyLang

while 1 = 1
   print "SPAM"
.

EDSAC order code

The EDSAC instruction set does not include an unconditional jump: it is necessary to synthesize it by using either an E "branch on accumulator sign bit clear" or F "branch on accumulator sign bit set" order, in circumstances where the condition is guaranteed to be met. For this specific task, guaranteeing it is trivial: printing characters does not change the contents of the accumulator at all. The solution presented here, however, is more general. We use a T "transfer and clear" order to store the accumulator's contents in storage address θ+17, then jump back to the beginning of the loop and reload the accumulator with an A "add" order. Note that the storage address used as a temporary variable should be set to zero on entry to the loop.

[ Infinite loop
  =============

  A program for the EDSAC

  Works with Initial Orders 2 ]

        T56K
        GK

        O10@  [ letter shift ]

[  1 ]  A17@  [ a += C(17@) ]
        O11@
        O12@
        O13@
        O14@
        O15@
        O16@
        T17@  [ C(17@) = a; a = 0 ]
        E1@   [ if a >= 0 goto 1@ ]

[ 10 ]  *F
[ 11 ]  SF
[ 12 ]  PF
[ 13 ]  AF
[ 14 ]  MF
[ 15 ]  @F    [ carriage return ]
[ 16 ]  &F    [ line feed ]

[ 17 ]  PF

        EZPF

Ela

Direct Approach

open monad io

loop () = do
  putStrLn "SPAM"
  loop ()

loop () ::: IO

Non-strict version

open monad io

xs = "SPAM"::xs

takeit 0 _ = do return ()
takeit num (x::xs) = do
  putStrLn x
  takeit (num - 1) xs

_ = takeit 10 xs ::: IO

Elena

ELENA 6.x:

public program()
{
    while (true)
    {
        console.writeLine("spam")
    }
}

Elixir

defmodule Loops do
  def infinite do
    IO.puts "SPAM"
    infinite
  end
end

Loops.infinite

or

Stream.cycle(["SPAM"]) |> Enum.each(&IO.puts &1)

Emacs Lisp

(while t
  (message "SPAM"))

EMal

for ever
  writeLine("SPAM")
end

Erlang

-module (main).
-export ([main/0]).

main() ->
  io:fwrite( "SPAM~n" ),
  main().

ERRE

LOOP
  PRINT("SPAM")
END LOOP

You can use also WHILE TRUE..END WHILE or REPEAT...UNTIL FALSE loops.

Euphoria

while 1 do
    puts(1, "SPAM\n")
end while

F#

// Imperative Solution
while true do
    printfn "SPAM"

// Functional solution
let rec forever () : unit =
    printfn "SPAM"
    forever ()

Factor

Tail recursion:

: spam ( -- ) "SPAM" print spam ;

Looping combinators:

[ "SPAM" print t ] loop
USE: combinators.extras
[ "SPAM" print ] forever

FALSE

[1]["SPAM
"]#

Fantom

class Main
{
  public static Void main ()
  {
    while (true) 
    {
      echo ("SPAM")
    }
  }
}

Fermat

while 1 do !!'SPAM'; od

Fish

a"MAPS"ooooo

Forth

: email   begin ." SPAM" cr again ;

Fortran

FORTRAN 77

      
   10 WRITE(*,*) 'SPAM'
      GO TO 10
      END

Fortran 90

program spam
  implicit none
  do
    write(*,*) 'SPAM'
  end do
end program spam

Fortress

component loops_infinite
  export Executable
  run() = while true do
    println("SPAM")
  end
end

FreeBASIC

' FB 1.05.0

Do
  Print "SPAM"
Loop

Frink

while true
   println["SPAM"]

FutureBasic

Loop de loop -- whose great idea was this?

include "NSLog.incl"

dispatchglobal
  while 1
    NSLog(@"SPAM")
  wend
dispatchend

HandleEvents

Gambas

Click this link to run this code

Public Sub Main()

Do
  Print "SPAM"
Loop

End

GAP

while true do
    Print("SPAM\n");
od;

GB BASIC

10 print "SPAM"
20 goto10

GDScript

Works with: Godot version 4.0.1
extends MainLoop


func _process(_delta: float) -> bool:
	print("SPAM")
	return false # _process loops until true is returned

GlovePIE

GlovePIE does not natively support multiple lines of output. As such, this code continuously changes the single line of output to SPAM. The below code does this without specifying an infinite loop because all GlovePIE scripts loop indefinitely until the program is stopped.

debug = "SPAM"

GML

while(1)
    show_message("SPAM")

Go

package main

import "fmt"

func main() {
	for {
		fmt.Printf("SPAM\n")
	}
}

Groovy

while (true) {
 println 'SPAM'
}

Halon

forever {
    echo "SPAM";
}

or (due to optimizations, these are equally fast)

while (true) {
    echo "SPAM";
}

Hare

use fmt;

export fn main() void = {
	for (true) {
		fmt::println("SPAM")!;
	};
};

Haskell

forever (putStrLn "SPAM")

or

import Control.Monad.Fix (fix)
fix (putStrLn "SPAM" >>)

Haxe

while (true)
  Sys.println("SPAM");

hexiscript

while true; println "SPAM"; endwhile

HicEst

DO i = 1, 1E20 ! for i with 16 or more digits:  i == i + 1 == loop infinite
    WRITE() "SPAM"
ENDDO

HolyC

while(1) Print("SPAM\n");

Icon and Unicon

There are several ways to write infinite loops in Icon. The most straightforward would be with repeat.

procedure main()
   repeat write("SPAM")
end

Alternately one could use one of these:

until &fail do write("SPAM")   # always fails, needs succeed to break
...
while write("SPAM")            # always succeeds, needs failure to break 
...
every write(|"SPAM")           # generator always succeeds, needs failure to break 
...
while write(|"SPAM")           # this is a common mistake that results in an endless loop
...
while write(1 to 5)            # a clearer version of the same mistake that generates endless 1's

IDL

while 1 do print,'SPAM'

Intercal

Assuming Turing Text I/O with 8-bit ASCII-compatible character set, using COME FROM:

       NOTE THIS IS INTERCAL
       PLEASE ,1 <- #5
       DO ,1 SUB #1 <- #54
       DO ,1 SUB #2 <- #192
       DO ,1 SUB #3 <- #136
       PLEASE ,1 SUB #4 <- #208
       DO ,1 SUB #5 <- #98
       DO COME FROM (1)
       DO READ OUT ,1
(2)    DO ,1 SUB #1 <- #134
(1)    PLEASE ABSTAIN FROM (2)

Io

loop("SPAM" println)

J

   ]F.(echo@'SPAM')0

Alternatively,

smoutput bind 'SPAM'^:1e99 ''

This second implementation relies on numeric inaccuracies in IEEE floating point notation. For example, 1+1e98 is exactly equal to 1e98. That said, 1e98 iterations would still be significantly longer than the practical life of any machine anyone would care to dedicate to this task.

Java

while (true) System.out.print("SPAM\n");
for (;;) System.out.print("SPAM\n");

JavaScript

for (;;) console.log("SPAM");
while (true) console.log("SPAM");

Joy

DEFINE loop == [true []] dip while.
["SPAM\n" putchars] loop.

jq

recurse("SPAM")
Output:
"SPAM"
"SPAM"
...

To suppress the quotation marks, invoke jq with the -r option.

Jsish

for (;;) puts('SPAM');

Julia

while true
    println("SPAM")
end
Output:
SPAM
SPAM
SPAM
SPAM
SPAM
SPAM
SPAM

and so on until ^C

K

   while[1; `0:"SPAM\n"]

Kotlin

// version 1.0.6

fun main(args: Array<String>) {
    while (true) println("SPAM")
}

LabVIEW

This image is a VI Snippet, an executable image of LabVIEW code. The LabVIEW version is shown on the top-right hand corner. You can download it, then drag-and-drop it onto the LabVIEW block diagram from a file browser, and it will appear as runnable, editable code.

Lambdatalk

{def loops_infinite
 {lambda {}
  {if true then SPAM{br} {loops_infinite} else never}}}
-> loops_infinite

{loops_infinite}
-> SPAM forever...

Lang

loop {
	fn.println(SPAM)
}

Lang5

do "SPAM\n" . loop

Lasso

// not wise to run this!
while(1 > 0) => {^
	'SPAM\r'
^}

LDPL

procedure:
label spam
display "SPAM" lf
goto spam

Liberty BASIC

<CTRL><Break> is used to terminate such loops.

while 1
  print "SPAM"
wend
end

Lily

while 1: print("SPAM")

Lingo

repeat while TRUE
  put "SPAM"
end repeat

Lisaac

{ "SPAM\n".print; }.endless_loop;

LiveCode

repeat forever
  put "SPAM" & return
end repeat

forever [print "SPAM]

LOLCODE

HAI
  CAN HAS STDIO?
  IM IN YR LOOP 
    VISIBLE "SPAM"
  IM OUTTA YR LOOP
KTHXBYE

Lua

while true do
  print("SPAM")
end

--Another solution
repeat
  print("SPAM")
until false

M2000 Interpreter

All loops can stop using Esc or Ctrl+C or Break (the last two open dialog box to stop or continue). Using Escape Off we make Esc not work for breaking execution. If Esc works then Ctrl + Y (and other letters except C, A, Z, X, N, M. F, L), open Control form, which we can do: Next Step, Slow Flow, Stop, and we can show code,current stack, variables, or execute immediate statements. This works only in console, not in M2000 forms.

Module CheckIt {
      Print "SPAM"
      loop
}
Checkit

Using a Repeat (or Do) - Always block

Module CheckIt {
      Repeat {
            Print "SPAM"
      } Always
}
Checkit

Printing text rendering using Report.

Module CheckIt {
      \\ stop in every 2/3 of cosole lines
      \\ press spacebar or mouse button to continue
      Report Format$("Spam\n")
      Loop
}
Checkit
\\ using multiline string, replace report from module above
Report {SPAM
            }

M4

define(`spam',`SPAM
spam')
spam

MACRO11

;	Infinte Loop under RT11
	.MCALL	.PRINT
	.EVEN
BEGIN:
LOOP:
	.PRINT #SPAM
	BR	LOOP
SPAM:	.ASCIZ	/SPAM/
	.END	BEGIN


MAD

            VECTOR VALUES SPAM = $4HSPAM*$
LOOP        PRINT FORMAT SPAM
            TRANSFER TO LOOP
            END OF PROGRAM

Make

spam:
   @echo SPAM
   $(MAKE)

Malbolge

bP&A@?>=<;:9876543210/.-,+*)('&%$T"!~}|;]yxwvutslUSRQ.yx+i)J9edFb4`_^]\yxwRQ)(TSRQ]m!G0KJIyxFvDa%_@?"=<5:98765.-2+*/.-,+*)('&%$#"!~}|utyrqvutsrqjonmPkjihgfedc\DDYAA\>>Y;;V886L5322G//D,,G))>&&A##!7~5:{y7xvuu,10/.-,+*)('&%$#"yb}|{zyxwvutmVqSohmOOjihafeHcEa`YAA\[ZYRW:U7SLKP3NMLK-I,GFED&%%@?>=6;|9y70/4u210/o-n+k)"!gg$#"!x}`{zyxZvYtsrqSoRmlkjLhKfedcEaD_^]\>Z=XWVU7S6QPON0LKDI,GFEDCBA#?"=};438y6543s1r/o-&%*k('&%e#d!~}|^z]xwvuWsVqponPlOjihgIeHcba`B^A\[ZY;W:UTSR4PI2MLKJ,,AFE(&B;:?"~<}{zz165v3s+*/pn,mk)jh&ge#db~a_{^\xwvoXsrqpRnmfkjMKg`_GG\aDB^A?[><X;9U86R53ONM0KJC,+FEDC&A@?!!6||3876w4-tr*/.-&+*)('&%$e"!~}|utyxwvutWlkponmlOjchg`edGba`_XW\?ZYRQVOT7RQPINML/JIHAFEDC&A@?>!<;{98yw5.-ss*/pn,+lj(!~ff{"ca}`^z][wZXtWUqTRnQOkNLhgfIdcFaZ_^A\[Z<XW:U8SRQPOHML/JIHG*ED=%%:?>=~;:{876w43210/(-,+*)('h%$d"ca}|_z\rqYYnsVTpoRPledLLafIGcbE`BXW??TY<:V97S64P31M0.J-+G*(DCB%@?"=<;|98765.3210p.-n+$)i'h%${"!~}|{zyxwvuXVlkpSQmlOjLbafIGcbE`BXW??TY<:V97S64P31M0.J-+G*(D'%A@?"=<}:98y6543,1r/.o,+*)j'&%eez!~a|^tsx[YutWUqjinQOkjMhJ`_dGEaDB^A?[><X;9U86R53O20LKJ-HG*ED'BA@?>7~;:{y7x5.3210q.-n+*)jh&%$#"c~}`{z]rwvutWrkpohmPkjihafI^cba`_^A\[>YXW:UTS5QP3NM0KJ-HGF?D'BA:?>=~;:z8765v32s0/.-nl$#(ig%fd"ca}|_]yrqvYWsVTpSQmPNjMKgJHdGEa`_B]\?ZY<WVUTMR5PO20LK.IHA))>CB%#?87}}49zx6wu3tr0qo-nl*ki'hf$ec!~}`{^yxwvotsrUponQlkMihKIe^]EEZ_B@\?=Y<:V97S64P31M0.J-+GFE(C&A@?8=<;:{876w43s10qo-&%kk"'hf$ec!b`|_]y\ZvYWsVTpSQmlkNiLgf_dcba`C^]\?ZY;WV97SLK33HM0.J-+G*(D'%A$">!};|z8yw543t1r/(-,+*)(i&%fd"!~}|_t]xwvutslqTonmPkjLhKIeHFbEC_^A?[TSX;9UT7R4JIN1/K.,H+)E(&B%#?"~<}{987x/4ussr).o,+l)(h&ge#db~a_{^\x[YutWrTjinQOkNLhgJeG]\aDB^]@[=SRW:877LQP3N0FEJ-+**?DC&A#98=~|:98yx/4u21rp(',mk)(ig%|{"ca}`^z][wZXtWUqTRnQOkNLhKIedcFE`YB@@?ZYRW:UTS6QPO11F..CHGF)(CB;@#>!~;XzV7gwu-QrrqMoJIkZF'WC$#AbQ`_{^L9wI64"VDConzl+j);JJ%qGFEZ~}]{ygwRuc8aSq44"H1Y.iV,e*RQ

Maple

> do print(SPAM) end;

Mathematica / Wolfram Language

While[True,
 Print@"SPAM";
 ]

MATLAB / Octave

while true
    fprintf('SPAM\n')
end

Maxima

do(disp("SPAM"));

MAXScript

while true do print "SPAM\n"

MelonBasic

Using Goto:1:

Say:"SPAM"
Goto:1

Using Goto:start:

Say:"SPAM"
Goto:start

Metafont

forever: message "SPAM"; endfor end

Microsoft Small Basic

With While.

While "True" 
  TextWindow.WriteLine("SPAM")
EndWhile

With Goto.

loopStart:
TextWindow.WriteLine("SPAM")
Goto loopStart

min

Works with: min version 0.19.3
(true) ("SPAM" puts!) while

MIPS Assembly

Thanks to Chibialiens.com for the header/footer, bitmap font, and print routines.

.include "\SrcAll\Header.asm"
.include "\SrcAll\BasicMacros.asm"
.include "\SrcPSX\MemoryMap.asm"
.include "\SrcN64\MemoryMap.asm"
  
CursorX equ 0x100 
CursorY equ 0x101
  
main:
	la a0,MyString
	jal PrintString
	nop
	jal NewLine
	nop
	j main
	nop
	
MyString:
	.byte "SPAM",255,0,0,0		;the 3 zeroes are padding to ensure proper alignment.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
MyFont:
.ifdef buildn64				
	.incbin "\ResN64\ChibiAkumas.fnt"
.endif
.ifdef buildPSX				
	.incbin "\ResPSX\ChibiAkumas.fnt"
.endif

.include "\SrcALL\graphics.asm"
	
.include "..\\SrcAll\monitor.asm"  	
.include "\SrcN64\Footer.asm"
Output:

Screenshot of Nintendo 64 emulator

МК-61/52

1	2	3	4	С/П	БП	00

Note: because this device has no text output instead of "SPAM" was used the number (1234).

Modula-2

LOOP
  InOut.WriteString ("SPAM");
  InOut.WriteLn
END;

Modula-3

LOOP
  IO.Put("SPAM\n");
END;

Monte

while (true):
    traceln("SPAM")

MontiLang

WHILE TRUE
    |SPAM| PRINT .
ENDWHILE

Note that TRUE is simply a variable equal to 1. WHILE 1, any number larger than 0 or any string with a length more than 0 would also work

MOO

while (1)
  player:tell("SPAM");
endwhile

MUMPS

 FOR  WRITE "SPAM",!

Nanoquery

while true
    println "SPAM"
end

Nemerle

while (true) WriteLine("SPAM");

Or, using recursion:

def loop() : void
{
    WriteLine("SPAM");
    loop();
}

NetRexx

/* NetRexx */
options replace format comments java crossref savelog symbols nobinary

  say
  say 'Loops/Infinite'

  loop label spam forever
    say 'SPAM'
    end spam

NewLISP

(while (println "SPAM"))

Nim

while true:
  echo "SPAM"

NS-HUBASIC

Using FOR:

10 FOR I=0 TO 1 STEP 0
20 PRINT "SPAM"
30 NEXT

Using GOTO:

10 PRINT "SPAM"
20 GOTO 10

Using RUN:

10 PRINT "SPAM"
20 RUN

Nu

while true {print SPAM}

Oberon-2

MODULE InfiniteLoop;
IMPORT 
  Out;
BEGIN
  LOOP
    Out.String("SPAM");Out.Ln
  END
END InfiniteLoop.

Objeck

while(true) {
  "SPAM"->PrintLine();
};

OCaml

while true do
  print_endline "SPAM"
done

or

let rec inf_loop() =    
  print_endline "SPAM";
  inf_loop()
in
inf_loop()

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.

Occam

#USE "course.lib"
PROC main (CHAN BYTE screen!)
  WHILE TRUE
    out.string("SPAM*c*n", 0, screen)
:

Octave

while(1)
  disp("SPAM")
endwhile

Oforth

begin "SPAM" . again

Ol

(let loop ()
   (display "SPAM")
   (loop))

OPL

PROC main:
  LOCAL loop%
  loop%=1
  while loop%=1
  PRINT "SPAM"
  ENDWH
ENDP

Oz

for do
   {Show 'SPAM'}
end

PARI/GP

while(1,
  print("SPAM")
);

For a shorter version, note that print returns gnil which is evaluated as false. A 'cheating' solution might use print(SPAM) on the hope that the variable SPAM is uninitialized and hence prints as the monomial in itself. But with the ' operator that evaluation can be forced, regardless of the current value (if any) of that variable:

until(print('SPAM),)

Pascal

while true do
  writeln('SPAM');

Alternatively:

repeat
  writeln('SPAM')
until false;

Perl

while(1){
    print "SPAM\n";
}

or equivalently

print "SPAM\n" while 1;

Phix

while true do
    puts(1,"SPAM\n")
end while

Phixmonti

/# Rosetta Code problem: https://rosettacode.org/w/index.php?title=Loops/Infinite
by Galileo, 11/2022 #/

true while "SPAM\n" print true endwhile

PHP

while(1)
    echo "SPAM\n";

PicoLisp

(loop (prinl "SPAM"))

Pike

while(1)
    write("SPAM\n");

PILOT

*TypeSpam
type:SPAM
jump:*TypeSpam

Pixilang

start:
fputs("SPAM\n")
go start

PL/I

do forever;
   put list ('SPAM'); put skip;
end;

PL/M

100H:
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; CALL BDOS(0,0); END EXIT;
PRINT: PROCEDURE (S); DECLARE S ADDRESS; CALL BDOS(9,S); END PRINT;

DECLARE SPAM    DATA ('SPAM',0DH,0AH,'$');

LOOP:  DO;

        CALL PRINT( .SPAM );
        GO TO LOOP;

END;
EOF

Plain English

When Repeat. appears by itself, execution proceeds from the beginning of the routine. Normally you would include a conditional statement to break or exit when a condition is met, but not in this case.

To run:
Start up.
Write SPAM forever.
Shut down.

To write SPAM forever:
Write "SPAM" to the console.
Repeat.

Plain TeX

Compile in console mode, with, e.g. "pdftex <file name>".

\newlinechar`\^^J
\def\spam{\message{SPAM^^J}\spam}%
\spam

Pop11

while true do
    printf('SPAM', '%p\n');
endwhile;

PostScript

simple infinite loop:

{}loop

A bit more complex infinite loop:

/go {
  /spam 
     { (SPAM\n) print flush } 
  bind def % bind and define spam

  { spam } % procedure that will be executed by loop and will call spam to print
  loop % the loop
}

%start spamming!
go

PowerShell

for () {
    "SPAM"
}

Prolog

repeat, write('SPAM'), nl, fail.

Pure Data

Screenshot: https://i.imgur.com/IrwaafZ.png

#N canvas 426 88 450 300 10;
#X obj 17 75 print;
#X msg 17 55 SPAM;
#X obj 17 35 metro 1;
#X msg 17 15 1;
#X connect 1 0 0 0;
#X connect 2 0 1 0;
#X connect 3 0 2 0;

Notes: the loop is started by clicking the |1(, a [loadbang] could additionally be used. An [until] object, sent a bang, will loop forever, but will hang Pure Data, whereas a high-speed metro will function perfectly.

PureBasic

Repeat/Forever

Repeat 
  PrintN("SPAM")
ForEver

Goto

PrintIt:
PrintN("SPAM")
Goto PrintIt

Python

In Python 2:

while 1:
   print "SPAM"

In python 3:

while 1:
   print("SPAM")

Note: one can also use: "True" or any other non-false value. In Python the following values are false: 0, "" (empty string), (,) and {} and [] (empty tuples, dictionaries or lists), None (the special object), and the False object. Any non-empty collection or string or non-zero numeric value is considered "True". However, according to Python Wiki, for Python versions 2.3+ this variant is optimized by the interpreter and thus is the fastest.

Quackery

[ say "SPAM" cr again ]

R

Note that the default R Gui buffers outputs before pushing them to the screen. To see this run either run in terminal mode, right click on the GUI window and deselect "Buffered Output" prior to execution, or add a call to flush.console() in the loop.

repeat print("SPAM")

Racket

#lang racket

;; Using recursion
(define (loop)
  (displayln "SPAM")
  (loop))

(loop)

;; Using a for loop
(for ([i (in-naturals)])
  (displayln "SPAM"))

Raku

(formerly Perl 6)

Works with: Rakudo Star version 2010.08
loop {
    say 'SPAM';
}

In addition, there are various ways of writing lazy, infinite lists in Raku:

print "SPAM\n" xx *;      # repetition operator
print "SPAM\n", ~* ... *; # sequence operator
map {say "SPAM"}, ^Inf;   # upto operator

Rapira

while 1 do
  output: "SPAM"
od

RATFOR

program loop

while (1==1)
write(*,101)"SPAM"
101 format(A)

end

REBOL

forever [print "SPAM"]

Red

forever [
print "SPAM"
]

ReScript

while true {
  Js.log("SPAM")
}

or

let rec inf_loop = () => {
  Js.log("SPAM")
  inf_loop()
}

Retro

[ "SPAM\n" puts -1 ] while

REXX

simple

/*REXX program displays the  word      SPAM      forever.               */

  do forever
  say 'SPAM'
  end   /*DO forever*/
                                       /*control will never reach here. */
                                       /*don't stick a fork in it.      */

esoteric

/*REXX program displays the  word      SPAM      forever.               */

   do  while  1==1                      /*esoteric  "forever"  clause.   */
   say 'SPAM'
   end   /*DO while 1==1*/
                                        /*control will never reach here. */
                                        /*don't stick a fork in it.      */

GO TO version

/*REXX program displays the  word      SPAM      forever.               */

tell_it:    say 'SPAM'
signal tell_it                         /*REXX's version of a  GO TO     */

                                       /*control will never reach here. */
                                       /*don't stick a fork in it.      */

too clever by half

/*REXX program displays the  word      SPAM      forever.               */

  do  until  0>1                       /*too-clever-by-half forever loop*/
  say 'SPAM'
  end   /*DO until 0>1*/
                                       /*control will never reach here. */
                                       /*don't stick a fork in it.      */

Ring

while true
      see "Spam"
end

Robotic

This will display the word SPAM at the bottom of the screen indefinitely:

: "infinite_loop"
* "SPAM"
goto "infinite_loop"

RPL

Usually in RPL, "printing" an object in RPL means putting it on top of the stack. In the present case, the loop would not be infinite since sooner or later the stack will overflow. But if the printer has an infinite paper roll, this will never stop:

≪ "SPAM" WHILE 1 REPEAT PR1 END ≫ EVAL

Ruby

loop {puts "SPAM"}

Run BASIC

[loop] print "Spam" :goto [loop]

while 1
print "Spam"
wend

Rust

fn main() {
    loop {
        println!("SPAM");
    }
}

S-lang

forever print("SPAM");

Salmon

while (true)
    "SPAM"!;

Sather

class MAIN is
  main is
    loop 
      #OUT + "Spam\n"; 
    end;
  end;
end;

Scala

while (true)
  println("SPAM")

Scheme

((lambda (x) (display "SPAM") (newline) (x x))
 (lambda (x) (display "SPAM") (newline) (x x)))

or, less Schemishly but with less redundancy:

(do () (#f) (display "SPAM") (newline))

Scilab

Works with: Scilab version 5.5.1
while %T
    printf("SPAM\n")
end
Output:
SPAM
SPAM
SPAM
SPAM
...

sed

:loop
s/.*/SPAM/
p
t loop

Sed requires at least one line of input to execute, so run as follows:

echo | sed ':loop;s/.*/SPAM/;p;t loop'

Seed7

$ include "seed7_05.s7i";

const proc: main is func
  begin
    while TRUE do
      writeln("SPAM");
    end while;
  end func;

Self

['SPAM' printLine] loop

Sidef

loop { say "SPAM!" };

Slate

[inform: 'SPAM'] loop

Smalltalk

[
    Transcript showCR:'boring stuff'.
] loop

[true] whileTrue:[
    Transcript showCR:'also borinh'.
]

[
    Transcript showCR:'poor cpu'.
] doUntil:[false]

[
    Transcript showCR:'please press CTRL-c!'.
] doWhile:[true]

SNOBOL4

loop output = "SPAM" :(loop)
end

SNUSP

@\>@\>@\>@\>++++++++++===!/ < < < < \
 |  |  |  \M=@@@@+@+++++# \.>.>.>.>./
 |  |  \A=@@+@@@@+++#
 |  \P=@@+@@+@@+++#
 \S=@@+@+@@@+++#

Sparkling

while true {
    print("SPAM");
}

or

do {
    print("SPAM");
} while true;

or

for var b = true; b; b = true {
    printf("SPAM\n");
}

etc.

Spin

Works with: BST/BSTC
Works with: FastSpin/FlexSpin
Works with: HomeSpun
Works with: OpenSpin
con
  _clkmode = xtal1 + pll16x
  _clkfreq = 80_000_000

obj
  ser : "FullDuplexSerial.spin"

pub main
  ser.start(31, 30, 0, 115200)

  repeat
    ser.str(string("SPAM",13,10))

  waitcnt(_clkfreq + cnt)
  ser.stop
  cogstop(0)

SPL

>
  #.output("SPAM")
<

SQL PL

Works with: Db2 LUW

version 9.7 or higher.

With SQL PL:

--#SET TERMINATOR @

SET SERVEROUTPUT ON@

BEGIN
 DECLARE I SMALLINT DEFAULT 1;
 WHILE (I = I) DO
  CALL DBMS_OUTPUT.PUT_LINE('SPAM');
 END WHILE;
END @

Output:

db2 -td@
db2 => SET SERVEROUTPUT ON@

db2 => BEGIN
...
db2 (cont.) => END @
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL20511N  There is not enough available space in the "DBMS_OUTPUT" message
buffer.  SQLSTATE=54035

SPAM
SPAM
SPAM
SPAM
...

Standard ML

while true do
  print "SPAM\n";

or

let 
  fun inf_loop () = (
    print "SPAM\n";
    inf_loop ()
  )
in
  inf_loop ()
end

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.

Stata

while 1 {
        display "SPAM"
}

Mata

while (1) printf("SPAM\n")

Also possible with a for loop, but unlike C, the middle expression is not optional:

for (;1;) printf("SPAM\n")

Swift

while true {
    println("SPAM")
}

SystemVerilog

program main;
  initial forever $display("SPAM");
endprogram

TailDot

c,x,SPAM,v,x,j,3

Tailspin

'SPAM$#10;' -> \(
  <> $ -> !OUT::write
     $ -> #
\) -> !VOID

Tcl

while true {
    puts SPAM
}
# or
for {} 1 {} {
    puts SPAM
}

TI-83 BASIC

There are a few ways to achieve this in TI-83 BASIC

  :Lbl 1
  :Disp "SPAM
  :Goto 1

Another way is by using a While loop

  :While 1
  :Disp "SPAM
  :End

TI-89 BASIC

Loop
  Disp "SPAM"
EndLoop

TorqueScript

While(1)
    echo("SPAM");

Transact-SQL

WHILE 1=1 BEGIN
 PRINT "SPAM"
END

Trith

["SPAM" print] loop

TUSCRIPT

TUSCRIPT has no infinite loop. 999999999 loops are the limit.

$$ MODE TUSCRIPT
LOOP/999999999
print "spam"
ENDLOOP

UNIX Shell

Works with: Bourne Shell

Use any of these loops:

while :; do echo SPAM; done
while true; do echo "SPAM"; done
until false; do echo "SPAM"; done
Works with: bash
Works with: ksh93
Works with: zsh
for ((;;)); do echo "SPAM"; done

C Shell

while (1)
	echo SPAM
end

es

forever {echo SPAM}

UnixPipes

yes SPAM

Unlambda

 ``ci``s``s`kr``s``s``s``s`k.S`k.P`k.A`k.Mii

Ursa

Translation of: Python
while true
	out "SPAM" endl console
end while

Uxntal

|0100
	&l ;SPAM <print-str> !&l

@<print-str> ( str* -- )
	&while ( -- )
		LDAk #18 DEO
		INC2 LDAk ?&while
	POP2 JMP2r

@SPAM
	"SPAM 0a $1

V

true [
   'SPAM' puts
] while

Vala

for(;;) stdout.printf("SPAM\n");
while(true) stdout.printf("SPAM\n");
do stdout.printf("SPAM\n"); while(true);

Vale

Works with: Vale version 0.2.0
import stdlib.*;

exported func main() {
	while true {
		println("SPAM");
	}
}

VAX Assembly

                               0000  0000     1 .entry	main,0
                   4D415053 8F   DD  0002     2 	pushl	#^a"SPAM"		;string on stack
                            5E   DD  0008     3 	pushl	sp			;reference to string
                            04   DD  000A     4 	pushl	#4			;+length = descriptor
                                     000C     5 loop:
                            5E   DD  000C     6 	pushl	sp			;descriptor by reference
              00000000'GF   01   FB  000E     7 	calls	#1, g^lib$put_output	;show message
                            F5   11  0015     8 	brb	loop			;forever
                                     0017     9 
                                     0017    10 .end	main

VBA

Do
   Debug.Print "SPAM"
Loop

VBScript

Do
    WScript.Echo("SPAM")
Loop

Vedit macro language

while (1) {
    Message("Spam\n")
}

or:

do {
    Message("Spam\n")
} while (1)

or:

for (;1;) {
    Message("Spam\n")
}

"Nearly infinite" loop can be done by using constant ALL (=1073741824) as repeat count:

Repeat (ALL) {
    Message("Spam\n")
}

Visual Basic

Do
    Debug.Print("SPAM")
Loop

Visual Basic .NET

Platform: .NET

Works with: Visual Basic .NET version 9.0+
Do
    Console.WriteLine("SPAM")
Loop

V (Vlang)

fn main() {
	for {
		print("SPAM\n")
	}
}

Wart

repeat :forever
  prn "spam"

Wee Basic

let loop=1
while loop=1
print 1 "SPAM"
wend
end


Whenever

1 print("SPAM");
1;


Wren

while (true) System.print("SPAM")

X86 Assembly

Works with: NASM version Linux
section .text
	global _start
	
	_start:
		mov edx, len
		mov ecx, msg
		mov ebx, 1
		mov eax, 4
		int 0x80
		jmp _start
		
section .data
msg		db "SPAM",0xa
len		equ $-msg

XLISP

It is of course possible to use a WHILE loop with a condition that will always evaluate to true:

(defun keep-printing-spam ()
    (while t
        (display "SPAM")
        (newline) ) )

Although this idiom is very common (in many programming languages), however, it feels a bit like a misuse of a looping construct that is meant to be conditional. If an unconditional jump is really what we want, then that is what we have goto for; or rather, in XLISP we do not have goto (in so many words) but we can achieve the effect of it using tail recursion.

(defun keep-printing-spam ()
    (display "SPAM")
    (newline)
    (keep-printing-spam) )

XPL0

code Text=12;
loop Text(0, "SPAM
")

Z80 Assembly

Using the Amstrad CPC firmware:

org		$4000

txt_output:	equ	$bb5a

start:		ld	hl,spam

print:		ld	a,(hl)
		cp	0
		jr	z,start
		call	txt_output
		inc	hl
		jr	print

spam:		defm	"SPAM\r\n\0"

Zig

const std = @import("std");
pub fn main() !void {
    const stdout_wr = std.io.getStdOut().writer();
    while (true) try stdout_wr.writeAll("SPAM\n");
}

zkl

while(1)   { println("SPAM") }
while(True){ println("SPAM") }
foreach _ in ([0..]){ println("SPAM") }
[0..].pump(Console.println,T(Void,"SPAM"));
[0..].pump(fcn{ println("SPAM") });
fcn{ println("SPAM"); return(self.fcn()) }(); // tail recursive lambda

Zoomscript

For typing:

var loop
loop = 1
while ne loop 0
	print "SPAM"
	println
endwhile

For importing:

¶0¶var loop¶0¶loop = 1¶0¶while ne loop 0¶1¶print "SPAM"¶1¶println¶0¶endwhile