Loops/Infinite: Difference between revisions
Content added Content deleted
m (→{{header|Joy}}) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 25: | Line 25: | ||
=={{header|11l}}== |
=={{header|11l}}== |
||
< |
<syntaxhighlight lang="11l">L |
||
print(‘SPAM’)</ |
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}}== |
||
< |
<syntaxhighlight lang="4dos">@echo off |
||
do forever |
do forever |
||
echo SPAM |
echo SPAM |
||
enddo</ |
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. |
||
< |
<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</ |
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</ |
.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. |
||
< |
<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</ |
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=== |
||
< |
<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</ |
jmp Spam</syntaxhighlight> |
||
===Loading From A Data Source=== |
===Loading From A Data Source=== |
||
< |
<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</ |
SpamMessage db "SPAM",13,10,0</syntaxhighlight> |
||
=={{header|8th}}== |
=={{header|8th}}== |
||
One way: |
One way: |
||
< |
<syntaxhighlight lang="forth"> |
||
: inf "SPAM\n" . recurse ; |
: inf "SPAM\n" . recurse ; |
||
</syntaxhighlight> |
|||
</lang> |
|||
Another way: |
Another way: |
||
< |
<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}}== |
||
< |
<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))))</ |
(spam))))</syntaxhighlight> |
||
=={{header|Action!}}== |
=={{header|Action!}}== |
||
< |
<syntaxhighlight lang="action!">PROC Main() |
||
DO |
DO |
||
PrintE("SPAM") |
PrintE("SPAM") |
||
OD |
OD |
||
RETURN</ |
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}}== |
||
< |
<syntaxhighlight lang="actionscript">while (true) { |
||
trace("SPAM"); |
trace("SPAM"); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
< |
<syntaxhighlight lang="ada">loop |
||
Put_Line("SPAM"); |
Put_Line("SPAM"); |
||
end loop;</ |
end loop;</syntaxhighlight> |
||
=={{header|Agena}}== |
=={{header|Agena}}== |
||
Tested with Agena 2.9.5 Win32 |
Tested with Agena 2.9.5 Win32 |
||
< |
<syntaxhighlight lang="agena">do |
||
print( "SPAM" ) |
print( "SPAM" ) |
||
od</ |
od</syntaxhighlight> |
||
=={{header|Aime}}== |
=={{header|Aime}}== |
||
< |
<syntaxhighlight lang="aime">while (1) { |
||
o_text("SPAM\n"); |
o_text("SPAM\n"); |
||
}</ |
}</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}} |
||
< |
<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'</ |
'END'</syntaxhighlight> |
||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
< |
<syntaxhighlight lang="algol68">DO |
||
printf($"SPAM"l$) |
printf($"SPAM"l$) |
||
OD</ |
OD</syntaxhighlight> |
||
Or the classic "dynamic halt": |
Or the classic "dynamic halt": |
||
< |
<syntaxhighlight lang="algol68">loop x: |
||
printf($"SPAM"l$); |
printf($"SPAM"l$); |
||
loop x</ |
loop x</syntaxhighlight> |
||
=={{header|ALGOL W}}== |
=={{header|ALGOL W}}== |
||
< |
<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.</ |
end.</syntaxhighlight> |
||
=={{header|AmigaE}}== |
=={{header|AmigaE}}== |
||
< |
<syntaxhighlight lang="amigae">PROC main() |
||
LOOP |
LOOP |
||
WriteF('SPAM') |
WriteF('SPAM') |
||
ENDLOOP |
ENDLOOP |
||
ENDPROC</ |
ENDPROC</syntaxhighlight> |
||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||
< |
<syntaxhighlight lang="applescript">repeat |
||
log "SPAM" |
log "SPAM" |
||
end repeat</ |
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}}== |
||
< |
<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</ |
YOU HAVE BEEN TERMINATED</syntaxhighlight> |
||
=={{header|Arturo}}== |
=={{header|Arturo}}== |
||
< |
<syntaxhighlight lang="rebol">while [true] [ |
||
print "SPAM" |
print "SPAM" |
||
]</ |
]</syntaxhighlight> |
||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
< |
<syntaxhighlight lang="autohotkey">Loop |
||
MsgBox SPAM `n</ |
MsgBox SPAM `n</syntaxhighlight> |
||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
< |
<syntaxhighlight lang="awk">BEGIN { |
||
while(1) { |
while(1) { |
||
print "SPAM" |
print "SPAM" |
||
} |
} |
||
}</ |
}</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. |
||
< |
<syntaxhighlight lang="axe">While 1 |
||
Disp "SPAM",i |
Disp "SPAM",i |
||
End</ |
End</syntaxhighlight> |
||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
{{works with|QuickBasic|4.5}} |
{{works with|QuickBasic|4.5}} |
||
Old-fashioned syntax: |
Old-fashioned syntax: |
||
< |
<syntaxhighlight lang="qbasic">while 1 |
||
print "SPAM" |
print "SPAM" |
||
wend</ |
wend</syntaxhighlight> |
||
Standard BASIC: |
Standard BASIC: |
||
< |
<syntaxhighlight lang="qbasic">do |
||
print "SPAM" |
print "SPAM" |
||
loop</ |
loop</syntaxhighlight> |
||
Also |
Also |
||
< |
<syntaxhighlight lang="qbasic">for i = 1 to 10 step 0 |
||
print "SPAM" |
print "SPAM" |
||
next i</ |
next i</syntaxhighlight> |
||
{{works with|Applesoft BASIC}} |
{{works with|Applesoft BASIC}} |
||
Line 365: | Line 365: | ||
The most intuitive method is to use the <code>GOTO</code> statement. |
The most intuitive method is to use the <code>GOTO</code> statement. |
||
< |
<syntaxhighlight lang="gwbasic">10 print "SPAM" |
||
20 goto 10</ |
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 386: | ||
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. |
||
< |
<syntaxhighlight lang="gwbasic">10 clr:print "Commodore Spam! ";:gosub 10</syntaxhighlight> |
||
< |
<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: |
||
< |
<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</ |
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. |
||
< |
<syntaxhighlight lang="gwbasic">10 print "Spam! "; |
||
20 run</ |
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... |
||
< |
<syntaxhighlight lang="gwbasic">10 print "SPAM SPAM! ";:if 1 then 10</syntaxhighlight> |
||
==={{header|Applesoft BASIC}}=== |
==={{header|Applesoft BASIC}}=== |
||
< |
<syntaxhighlight lang="applesoftbasic">FOR I = 0 TO 1 STEP 0 : PRINT "SPAM" : NEXT</syntaxhighlight> |
||
==={{header|BASIC256}}=== |
==={{header|BASIC256}}=== |
||
< |
<syntaxhighlight lang="basic256">while true |
||
print "SPAM" |
print "SPAM" |
||
end while</ |
end while</syntaxhighlight> |
||
==={{header|Commodore BASIC}}=== |
==={{header|Commodore BASIC}}=== |
||
Line 448: | Line 448: | ||
==={{header|IS-BASIC}}=== |
==={{header|IS-BASIC}}=== |
||
< |
<syntaxhighlight lang="is-basic">100 DO |
||
110 PRINT "SPAM" |
110 PRINT "SPAM" |
||
120 LOOP</ |
120 LOOP</syntaxhighlight> |
||
==={{header|QB64}}=== |
==={{header|QB64}}=== |
||
< |
<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 461: | ||
While 1 |
While 1 |
||
Print "SPAM" |
Print "SPAM" |
||
Wend</ |
Wend</syntaxhighlight> |
||
==={{header|True BASIC}}=== |
==={{header|True BASIC}}=== |
||
< |
<syntaxhighlight lang="qbasic">DO |
||
PRINT "SPAM" |
PRINT "SPAM" |
||
LOOP |
LOOP |
||
END</ |
END</syntaxhighlight> |
||
==={{header|Yabasic}}=== |
==={{header|Yabasic}}=== |
||
<syntaxhighlight lang="yabasic">do |
|||
<lang Yabasic>do |
|||
print "SPAM" |
print "SPAM" |
||
loop</ |
loop</syntaxhighlight> |
||
O también |
O también |
||
< |
<syntaxhighlight lang="yabasic">while true |
||
print "SPAM" |
print "SPAM" |
||
wend</ |
wend</syntaxhighlight> |
||
=={{header|Batch File}}== |
=={{header|Batch File}}== |
||
Using <code>goto</code>: |
Using <code>goto</code>: |
||
< |
<syntaxhighlight lang="dos">@echo off |
||
:loop |
:loop |
||
echo SPAM |
echo SPAM |
||
goto loop</ |
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}} |
||
< |
<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}}== |
||
< |
<syntaxhighlight lang="bbcbasic"> REPEAT |
||
PRINT "SPAM" |
PRINT "SPAM" |
||
UNTIL FALSE</ |
UNTIL FALSE</syntaxhighlight> |
||
=={{header|bc}}== |
=={{header|bc}}== |
||
< |
<syntaxhighlight lang="bc">while (1) "SPAM |
||
"</ |
"</syntaxhighlight> |
||
=={{header|BCPL}}== |
=={{header|BCPL}}== |
||
< |
<syntaxhighlight lang="bcpl">get "libhdr" |
||
let start() be writes("SPAM*N") repeat</ |
let start() be writes("SPAM*N") repeat</syntaxhighlight> |
||
=={{header|beeswax}}== |
=={{header|beeswax}}== |
||
< |
<syntaxhighlight lang="beeswax">_>`SPA`p |
||
bN`M`<</ |
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 '''@'''. |
||
< |
<syntaxhighlight lang="befunge">55+"MAPS",,,,,</syntaxhighlight> |
||
=={{header|blz}}== |
=={{header|blz}}== |
||
< |
<syntaxhighlight lang="blz">while true |
||
print("SPAM") |
print("SPAM") |
||
end</ |
end</syntaxhighlight> |
||
=={{header|bootBASIC}}== |
=={{header|bootBASIC}}== |
||
Using <code>goto</code>: |
Using <code>goto</code>: |
||
< |
<syntaxhighlight lang="bootbasic">10 print "SPAM" |
||
20 goto 10</ |
20 goto 10</syntaxhighlight> |
||
Using <code>run</code>: |
Using <code>run</code>: |
||
< |
<syntaxhighlight lang="bootbasic">10 print "SPAM" |
||
20 run</ |
20 run</syntaxhighlight> |
||
=={{header|BQN}}== |
=={{header|BQN}}== |
||
Line 533: | Line 533: | ||
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. |
||
< |
<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 |
<syntaxhighlight lang="bracmat">whl'out$SPAM</syntaxhighlight> |
||
=={{header|Brainf***}}== |
=={{header|Brainf***}}== |
||
Optimized for code size: |
Optimized for code size: |
||
< |
<syntaxhighlight lang="bf">++++++++++[->++++++>++++++++>+<<<]>+++++> |
||
[+++.---.<.>---.+++>.<]</ |
[+++.---.<.>---.+++>.<]</syntaxhighlight> |
||
Optimized for execution speed: |
Optimized for execution speed: |
||
< |
<syntaxhighlight lang="bf">10++++++++++ |
||
[-> 8++++++++ > 8++++++++ > 6++++++ > 8++++++++ > 1+ <<<<<]> |
[-> 8++++++++ > 8++++++++ > 6++++++ > 8++++++++ > 1+ <<<<<]> |
||
83+++ > 80 > 65+++++ > 77--- <<< |
83+++ > 80 > 65+++++ > 77--- <<< |
||
[.>.>.>.>.<<<<]</ |
[.>.>.>.>.<<<<]</syntaxhighlight> |
||
=={{header|Brat}}== |
=={{header|Brat}}== |
||
< |
<syntaxhighlight lang="brat">loop { p "SPAM" }</syntaxhighlight> |
||
=={{header|C}}== |
=={{header|C}}== |
||
< |
<syntaxhighlight lang="c">while(1) puts("SPAM");</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="c"> for(;;) puts("SPAM");</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="c">do { puts("SPAM"); } while(1);</syntaxhighlight> |
||
or |
or |
||
< |
<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#}}== |
||
< |
<syntaxhighlight lang="csharp">while (true) |
||
{ |
{ |
||
Console.WriteLine("SPAM"); |
Console.WriteLine("SPAM"); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|C++}}== |
=={{header|C++}}== |
||
{{trans|C}} |
{{trans|C}} |
||
< |
<syntaxhighlight lang="cpp">while (true) |
||
std::cout << "SPAM\n";</ |
std::cout << "SPAM\n";</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="cpp">for (;;) |
||
std::cout << "SPAM\n";</ |
std::cout << "SPAM\n";</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="cpp">do |
||
std::cout << "SPAM\n"; |
std::cout << "SPAM\n"; |
||
while (true);</ |
while (true);</syntaxhighlight> |
||
=={{header|Chapel}}== |
=={{header|Chapel}}== |
||
< |
<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}}== |
||
< |
<syntaxhighlight lang="lisp">(loop [] (println "SPAM") (recur))</syntaxhighlight> |
||
=={{header|COBOL}}== |
=={{header|COBOL}}== |
||
< |
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION. |
||
PROGRAM-ID. Spam. |
PROGRAM-ID. Spam. |
||
Line 608: | Line 608: | ||
GOBACK |
GOBACK |
||
.</ |
.</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}}== |
||
< |
<syntaxhighlight lang="coffeescript">loop |
||
console.log 'SPAM' |
console.log 'SPAM' |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|ColdFusion}}== |
=={{header|ColdFusion}}== |
||
Line 620: | Line 620: | ||
With tags: |
With tags: |
||
< |
<syntaxhighlight lang="cfm"><cfloop condition = "true NEQ false"> |
||
SPAM |
SPAM |
||
</cfloop></ |
</cfloop></syntaxhighlight> |
||
With script: |
With script: |
||
< |
<syntaxhighlight lang="cfm"><cfscript> |
||
while( true != false ) |
while( true != false ) |
||
{ |
{ |
||
writeOutput( "SPAM" ); |
writeOutput( "SPAM" ); |
||
} |
} |
||
</cfscript></ |
</cfscript></syntaxhighlight> |
||
=={{header|Comal}}== |
=={{header|Comal}}== |
||
< |
<syntaxhighlight lang="comal">LOOP |
||
PRINT "SPAM" |
PRINT "SPAM" |
||
ENDLOOP</ |
ENDLOOP</syntaxhighlight> |
||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
< |
<syntaxhighlight lang="lisp">(loop (write-line "SPAM"))</syntaxhighlight> |
||
=== Using DO === |
=== Using DO === |
||
< |
<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 653: | ||
=={{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}}== |
||
< |
<syntaxhighlight lang="cowgol">include "cowgol.coh"; |
||
loop |
loop |
||
print("Spam\n"); |
print("Spam\n"); |
||
end loop;</ |
end loop;</syntaxhighlight> |
||
=={{header|Crystal}}== |
=={{header|Crystal}}== |
||
< |
<syntaxhighlight lang="crystal">loop do |
||
puts "SPAM" |
puts "SPAM" |
||
end</ |
end</syntaxhighlight> |
||
Using <code>while</code>/<code>until</code>: |
Using <code>while</code>/<code>until</code>: |
||
< |
<syntaxhighlight lang="crystal">while true |
||
puts "SPAM" |
puts "SPAM" |
||
end</ |
end</syntaxhighlight> |
||
< |
<syntaxhighlight lang="crystal">until false |
||
puts "SPAM" |
puts "SPAM" |
||
end</ |
end</syntaxhighlight> |
||
Using an infinite range: |
Using an infinite range: |
||
< |
<syntaxhighlight lang="crystal">(0..).each do |
||
puts "SPAM" |
puts "SPAM" |
||
end</ |
end</syntaxhighlight> |
||
=={{header|D}}== |
=={{header|D}}== |
||
Some common ways to create an infinite printing loop: |
Some common ways to create an infinite printing loop: |
||
< |
<syntaxhighlight lang="d">import std.stdio; |
||
void main() { |
void main() { |
||
while (true) |
while (true) |
||
writeln("SPAM"); |
writeln("SPAM"); |
||
}</ |
}</syntaxhighlight> |
||
< |
<syntaxhighlight lang="d">import std.stdio; |
||
void main() { |
void main() { |
||
Line 699: | Line 699: | ||
writeln("SPAM"); |
writeln("SPAM"); |
||
while (true); |
while (true); |
||
}</ |
}</syntaxhighlight> |
||
< |
<syntaxhighlight lang="d">import std.stdio; |
||
void main() { |
void main() { |
||
for ( ; ; ) |
for ( ; ; ) |
||
writeln("SPAM"); |
writeln("SPAM"); |
||
}</ |
}</syntaxhighlight> |
||
< |
<syntaxhighlight lang="d">import std.stdio; |
||
void main() { |
void main() { |
||
Line 714: | Line 714: | ||
writeln("SPAM"); |
writeln("SPAM"); |
||
goto LOOP; |
goto LOOP; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Dart}}== |
=={{header|Dart}}== |
||
<lang> |
<syntaxhighlight lang="text"> |
||
main() { |
main() { |
||
while(true) { |
while(true) { |
||
Line 723: | Line 723: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|dc}}== |
=={{header|dc}}== |
||
< |
<syntaxhighlight lang="dc">[[SPAM |
||
]P dx]dx</ |
]P dx]dx</syntaxhighlight> |
||
This loop is a tail-recursive function. |
This loop is a tail-recursive function. |
||
Line 735: | Line 735: | ||
=={{header|DCL}}== |
=={{header|DCL}}== |
||
< |
<syntaxhighlight lang="dcl">$ loop: |
||
$ write sys$output "SPAM" |
$ write sys$output "SPAM" |
||
$ goto loop</ |
$ goto loop</syntaxhighlight> |
||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
Line 743: | Line 743: | ||
=={{header|Draco}}== |
=={{header|Draco}}== |
||
< |
<syntaxhighlight lang="draco">proc nonrec main() void: |
||
while true do |
while true do |
||
writeln("SPAM") |
writeln("SPAM") |
||
od |
od |
||
corp</ |
corp</syntaxhighlight> |
||
=={{header|DWScript}}== |
=={{header|DWScript}}== |
||
< |
<syntaxhighlight lang="delphi">while True do |
||
PrintLn('SPAM');</ |
PrintLn('SPAM');</syntaxhighlight> |
||
=={{header|Dyalect}}== |
=={{header|Dyalect}}== |
||
< |
<syntaxhighlight lang="dyalect">while true { |
||
print("SPAM") |
print("SPAM") |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Déjà Vu}}== |
=={{header|Déjà Vu}}== |
||
< |
<syntaxhighlight lang="dejavu">while true: |
||
!print "SPAM"</ |
!print "SPAM"</syntaxhighlight> |
||
Infinite recursion thanks to tail calls: |
Infinite recursion thanks to tail calls: |
||
< |
<syntaxhighlight lang="dejavu">labda: |
||
!print "SPAM" |
!print "SPAM" |
||
recurse |
recurse |
||
call</ |
call</syntaxhighlight> |
||
=={{header|E}}== |
=={{header|E}}== |
||
< |
<syntaxhighlight lang="e">while (true) { |
||
println("SPAM") |
println("SPAM") |
||
}</ |
}</syntaxhighlight> |
||
< |
<syntaxhighlight lang="e">def f() { |
||
println("SPAM") |
println("SPAM") |
||
f <- () |
f <- () |
||
} |
} |
||
f <- ()</ |
f <- ()</syntaxhighlight> |
||
The difference between these is that in the second, |
The difference between these is that in the second, |
||
Line 787: | Line 787: | ||
=={{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. |
||
< |
<syntaxhighlight lang="edsac">[ Infinite loop |
||
============= |
============= |
||
Line 819: | Line 819: | ||
[ 17 ] PF |
[ 17 ] PF |
||
EZPF</ |
EZPF</syntaxhighlight> |
||
=={{header|Ela}}== |
=={{header|Ela}}== |
||
Line 825: | Line 825: | ||
===Direct Approach=== |
===Direct Approach=== |
||
< |
<syntaxhighlight lang="ela">open monad io |
||
loop () = do |
loop () = do |
||
Line 831: | Line 831: | ||
loop () |
loop () |
||
loop () ::: IO</ |
loop () ::: IO</syntaxhighlight> |
||
===Non-strict version=== |
===Non-strict version=== |
||
< |
<syntaxhighlight lang="ela">open monad io |
||
xs = "SPAM"::xs |
xs = "SPAM"::xs |
||
Line 844: | Line 844: | ||
takeit (num - 1) xs |
takeit (num - 1) xs |
||
_ = takeit 10 xs ::: IO</ |
_ = takeit 10 xs ::: IO</syntaxhighlight> |
||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA 4.x: |
ELENA 4.x: |
||
< |
<syntaxhighlight lang="elena">public program() |
||
{ |
{ |
||
while (true) |
while (true) |
||
Line 854: | Line 854: | ||
console.writeLine:"spam" |
console.writeLine:"spam" |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Elixir}}== |
=={{header|Elixir}}== |
||
< |
<syntaxhighlight lang="elixir">defmodule Loops do |
||
def infinite do |
def infinite do |
||
IO.puts "SPAM" |
IO.puts "SPAM" |
||
Line 864: | Line 864: | ||
end |
end |
||
Loops.infinite</ |
Loops.infinite</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="elixir">Stream.cycle(["SPAM"]) |> Enum.each(&IO.puts &1)</syntaxhighlight> |
||
=={{header|Emacs Lisp}}== |
=={{header|Emacs Lisp}}== |
||
< |
<syntaxhighlight lang="lisp">(while t |
||
(message "SPAM"))</ |
(message "SPAM"))</syntaxhighlight> |
||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
< |
<syntaxhighlight lang="erlang"> |
||
-module (main). |
-module (main). |
||
-export ([main/0]). |
-export ([main/0]). |
||
Line 881: | Line 881: | ||
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#}}== |
||
< |
<syntaxhighlight lang="fsharp"> |
||
// Imperative Solution |
// Imperative Solution |
||
while true do |
while true do |
||
Line 908: | Line 908: | ||
printfn "SPAM" |
printfn "SPAM" |
||
forever () |
forever () |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
Tail recursion: |
Tail recursion: |
||
< |
<syntaxhighlight lang="factor">: spam ( -- ) "SPAM" print spam ;</syntaxhighlight> |
||
Looping combinators: |
Looping combinators: |
||
< |
<syntaxhighlight lang="factor">[ "SPAM" print t ] loop</syntaxhighlight> |
||
< |
<syntaxhighlight lang="factor">USE: combinators.extras |
||
[ "SPAM" print ] forever</ |
[ "SPAM" print ] forever</syntaxhighlight> |
||
=={{header|FALSE}}== |
=={{header|FALSE}}== |
||
< |
<syntaxhighlight lang="false">[1]["SPAM |
||
"]#</ |
"]#</syntaxhighlight> |
||
=={{header|Fantom}}== |
=={{header|Fantom}}== |
||
< |
<syntaxhighlight lang="fantom"> |
||
class Main |
class Main |
||
{ |
{ |
||
Line 935: | Line 935: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Fermat}}== |
=={{header|Fermat}}== |
||
< |
<syntaxhighlight lang="fermat">while 1 do !!'SPAM'; od</syntaxhighlight> |
||
=={{header|Fish}}== |
=={{header|Fish}}== |
||
< |
<syntaxhighlight lang="fish">a"MAPS"ooooo</syntaxhighlight> |
||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
< |
<syntaxhighlight lang="forth">: email begin ." SPAM" cr again ;</syntaxhighlight> |
||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
FORTRAN 77 |
FORTRAN 77 |
||
< |
<syntaxhighlight lang="fortran"> |
||
10 WRITE(*,*) 'SPAM' |
10 WRITE(*,*) 'SPAM' |
||
GO TO 10 |
GO TO 10 |
||
END |
END |
||
</syntaxhighlight> |
|||
</lang> |
|||
Fortran 90 |
Fortran 90 |
||
< |
<syntaxhighlight lang="fortran"> |
||
program spam |
program spam |
||
implicit none |
implicit none |
||
Line 962: | Line 962: | ||
end do |
end do |
||
end program spam |
end program spam |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Fortress}}== |
=={{header|Fortress}}== |
||
< |
<syntaxhighlight lang="fortress"> |
||
component loops_infinite |
component loops_infinite |
||
export Executable |
export Executable |
||
Line 972: | Line 972: | ||
end |
end |
||
end |
end |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
< |
<syntaxhighlight lang="freebasic">' FB 1.05.0 |
||
Do |
Do |
||
Print "SPAM" |
Print "SPAM" |
||
Loop</ |
Loop</syntaxhighlight> |
||
=={{header|Frink}}== |
=={{header|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? |
||
< |
<syntaxhighlight lang="futurebasic">include "NSLog.incl" |
||
dispatchglobal |
dispatchglobal |
||
Line 997: | Line 997: | ||
dispatchend |
dispatchend |
||
HandleEvents</ |
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]''' |
||
< |
<syntaxhighlight lang="gambas">Public Sub Main() |
||
Do |
Do |
||
Line 1,007: | Line 1,007: | ||
Loop |
Loop |
||
End</ |
End</syntaxhighlight> |
||
=={{header|GAP}}== |
=={{header|GAP}}== |
||
< |
<syntaxhighlight lang="gap">while true do |
||
Print("SPAM\n"); |
Print("SPAM\n"); |
||
od;</ |
od;</syntaxhighlight> |
||
=={{header|GB BASIC}}== |
=={{header|GB BASIC}}== |
||
< |
<syntaxhighlight lang="gb basic">10 print "SPAM" |
||
20 goto10</ |
20 goto10</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. |
||
< |
<syntaxhighlight lang="glovepie">debug = "SPAM"</syntaxhighlight> |
||
=={{header|GML}}== |
=={{header|GML}}== |
||
< |
<syntaxhighlight lang="gml">while(1) |
||
show_message("SPAM")</ |
show_message("SPAM")</syntaxhighlight> |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
< |
<syntaxhighlight lang="go">package main |
||
import "fmt" |
import "fmt" |
||
Line 1,035: | Line 1,035: | ||
fmt.Printf("SPAM\n") |
fmt.Printf("SPAM\n") |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
< |
<syntaxhighlight lang="groovy">while (true) { |
||
println 'SPAM' |
println 'SPAM' |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Halon}}== |
=={{header|Halon}}== |
||
< |
<syntaxhighlight lang="halon">forever { |
||
echo "SPAM"; |
echo "SPAM"; |
||
}</ |
}</syntaxhighlight> |
||
or (due to optimizations, these are equally fast) |
or (due to optimizations, these are equally fast) |
||
< |
<syntaxhighlight lang="halon">while (true) { |
||
echo "SPAM"; |
echo "SPAM"; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Hare}}== |
=={{header|Hare}}== |
||
< |
<syntaxhighlight lang="hare">use fmt; |
||
export fn main() void = { |
export fn main() void = { |
||
Line 1,058: | Line 1,058: | ||
fmt::println("SPAM")!; |
fmt::println("SPAM")!; |
||
}; |
}; |
||
};</ |
};</syntaxhighlight> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
< |
<syntaxhighlight lang="haskell">forever (putStrLn "SPAM")</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="haskell">import Control.Monad.Fix (fix) |
||
fix (putStrLn "SPAM" >>) </ |
fix (putStrLn "SPAM" >>) </syntaxhighlight> |
||
=={{header|Haxe}}== |
=={{header|Haxe}}== |
||
< |
<syntaxhighlight lang="haxe">while (true) |
||
Sys.println("SPAM");</ |
Sys.println("SPAM");</syntaxhighlight> |
||
=={{header|hexiscript}}== |
=={{header|hexiscript}}== |
||
< |
<syntaxhighlight lang="hexiscript">while true; println "SPAM"; endwhile</syntaxhighlight> |
||
=={{header|HicEst}}== |
=={{header|HicEst}}== |
||
< |
<syntaxhighlight lang="hicest">DO i = 1, 1E20 ! for i with 16 or more digits: i == i + 1 == loop infinite |
||
WRITE() "SPAM" |
WRITE() "SPAM" |
||
ENDDO</ |
ENDDO</syntaxhighlight> |
||
=={{header|HolyC}}== |
=={{header|HolyC}}== |
||
< |
<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. |
||
< |
<syntaxhighlight lang="icon">procedure main() |
||
repeat write("SPAM") |
repeat write("SPAM") |
||
end</ |
end</syntaxhighlight> |
||
Alternately one could use one of these: |
Alternately one could use one of these: |
||
< |
<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,096: | Line 1,096: | ||
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</ |
while write(1 to 5) # a clearer version of the same mistake that generates endless 1's</syntaxhighlight> |
||
=={{header|IDL}}== |
=={{header|IDL}}== |
||
<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: |
||
< |
<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,114: | Line 1,114: | ||
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)</ |
(1) PLEASE ABSTAIN FROM (2)</syntaxhighlight> |
||
=={{header|Io}}== |
=={{header|Io}}== |
||
< |
<syntaxhighlight lang="io">loop("SPAM" println)</syntaxhighlight> |
||
=={{header|J}}== |
=={{header|J}}== |
||
< |
<syntaxhighlight lang="j">(-[smoutput bind 'SPAM')^:_(1)</syntaxhighlight> |
||
Alternatively, |
Alternatively, |
||
< |
<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,132: | Line 1,132: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
< |
<syntaxhighlight lang="java">while (true) { |
||
System.out.println("SPAM"); |
System.out.println("SPAM"); |
||
}</ |
}</syntaxhighlight> |
||
< |
<syntaxhighlight lang="java">for (;;) { |
||
System.out.println("SPAM"); |
System.out.println("SPAM"); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
< |
<syntaxhighlight lang="javascript">for (;;) console.log("SPAM");</syntaxhighlight> |
||
< |
<syntaxhighlight lang="javascript">while (true) console.log("SPAM");</syntaxhighlight> |
||
=={{header|Joy}}== |
=={{header|Joy}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="joy">DEFINE loop == [true []] dip while. |
||
["SPAM\n" putchars] loop.</syntaxhighlight> |
["SPAM\n" putchars] loop.</syntaxhighlight> |
||
=={{header|jq}}== |
=={{header|jq}}== |
||
< |
<syntaxhighlight lang="jq">recurse("SPAM")</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
"SPAM" |
"SPAM" |
||
Line 1,158: | Line 1,158: | ||
=={{header|Jsish}}== |
=={{header|Jsish}}== |
||
< |
<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,179: | Line 1,179: | ||
=={{header|K}}== |
=={{header|K}}== |
||
< |
<syntaxhighlight lang="k"> while[1; `0:"SPAM\n"]</syntaxhighlight> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
< |
<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") |
||
}</ |
}</syntaxhighlight> |
||
=={{header|LabVIEW}}== |
=={{header|LabVIEW}}== |
||
Line 1,192: | Line 1,192: | ||
=={{header|Lambdatalk}}== |
=={{header|Lambdatalk}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
{def loops_infinite |
{def loops_infinite |
||
{lambda {} |
{lambda {} |
||
Line 1,200: | Line 1,200: | ||
{loops_infinite} |
{loops_infinite} |
||
-> SPAM forever... |
-> SPAM forever... |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Lang5}}== |
=={{header|Lang5}}== |
||
< |
<syntaxhighlight lang="lang5">do "SPAM\n" . loop</syntaxhighlight> |
||
=={{header|Lasso}}== |
=={{header|Lasso}}== |
||
< |
<syntaxhighlight lang="lasso">// not wise to run this! |
||
while(1 > 0) => {^ |
while(1 > 0) => {^ |
||
'SPAM\r' |
'SPAM\r' |
||
^}</ |
^}</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}}== |
||
< |
<syntaxhighlight lang="lily"> |
||
while 1: print("SPAM") |
while 1: print("SPAM") |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Lingo}}== |
=={{header|Lingo}}== |
||
< |
<syntaxhighlight lang="lingo">repeat while TRUE |
||
put "SPAM" |
put "SPAM" |
||
end repeat</ |
end repeat</syntaxhighlight> |
||
=={{header|Lisaac}}== |
=={{header|Lisaac}}== |
||
Line 1,236: | Line 1,236: | ||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |
||
< |
<syntaxhighlight lang="livecode">repeat forever |
||
put "SPAM" & return |
put "SPAM" & return |
||
end repeat</ |
end repeat</syntaxhighlight> |
||
=={{header|Logo}}== |
=={{header|Logo}}== |
||
< |
<syntaxhighlight lang="logo">forever [print "SPAM]</syntaxhighlight> |
||
=={{header|LOLCODE}}== |
=={{header|LOLCODE}}== |
||
< |
<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</ |
KTHXBYE</syntaxhighlight> |
||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
< |
<syntaxhighlight lang="lua"> |
||
while true do |
while true do |
||
print("SPAM") |
print("SPAM") |
||
Line 1,261: | Line 1,261: | ||
print("SPAM") |
print("SPAM") |
||
until false |
until false |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|M2000 Interpreter}}== |
=={{header|M2000 Interpreter}}== |
||
Line 1,267: | Line 1,267: | ||
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,273: | Line 1,273: | ||
} |
} |
||
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,282: | Line 1,282: | ||
} |
} |
||
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,296: | Line 1,296: | ||
Report {SPAM |
Report {SPAM |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|M4}}== |
=={{header|M4}}== |
||
< |
<syntaxhighlight lang="m4">define(`spam',`SPAM |
||
spam') |
spam') |
||
spam</ |
spam</syntaxhighlight> |
||
=={{header|Make}}== |
=={{header|Make}}== |
||
< |
<syntaxhighlight lang="make">spam: |
||
@echo SPAM |
@echo SPAM |
||
$(MAKE)</ |
$(MAKE)</syntaxhighlight> |
||
=={{header|Malbolge}}== |
=={{header|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}}== |
||
< |
<syntaxhighlight lang="mathematica">While[True, |
||
Print@"SPAM"; |
Print@"SPAM"; |
||
]</ |
]</syntaxhighlight> |
||
=={{header|MATLAB}} / {{header|Octave}}== |
=={{header|MATLAB}} / {{header|Octave}}== |
||
< |
<syntaxhighlight lang="matlab">while true |
||
fprintf('SPAM\n') |
fprintf('SPAM\n') |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Maxima}}== |
=={{header|Maxima}}== |
||
< |
<syntaxhighlight lang="maxima">do(disp("SPAM"));</syntaxhighlight> |
||
=={{header|MAXScript}}== |
=={{header|MAXScript}}== |
||
< |
<syntaxhighlight lang="maxscript">while true do print "SPAM\n"</syntaxhighlight> |
||
=={{header|MelonBasic}}== |
=={{header|MelonBasic}}== |
||
Using <code>Goto:1</code>: |
Using <code>Goto:1</code>: |
||
< |
<syntaxhighlight lang="melonbasic">Say:"SPAM" |
||
Goto:1</ |
Goto:1</syntaxhighlight> |
||
Using <code>Goto:start</code>: |
Using <code>Goto:start</code>: |
||
< |
<syntaxhighlight lang="melonbasic">Say:"SPAM" |
||
Goto:start</ |
Goto:start</syntaxhighlight> |
||
=={{header|Metafont}}== |
=={{header|Metafont}}== |
||
< |
<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>. |
||
< |
<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>. |
||
< |
<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}} |
||
< |
<syntaxhighlight lang="min">(true) ("SPAM" puts!) while</syntaxhighlight> |
||
=={{header|MIPS Assembly}}== |
=={{header|MIPS Assembly}}== |
||
Thanks to [https://www.chibialiens.com/mips/ Chibialiens.com] for the header/footer, bitmap font, and print routines. |
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 "\SrcAll\BasicMacros.asm" |
||
.include "\SrcPSX\MemoryMap.asm" |
.include "\SrcPSX\MemoryMap.asm" |
||
Line 1,400: | Line 1,400: | ||
.include "..\\SrcAll\monitor.asm" |
.include "..\\SrcAll\monitor.asm" |
||
.include "\SrcN64\Footer.asm"</ |
.include "\SrcN64\Footer.asm"</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
[https://ibb.co/rpH9bVR Screenshot of Nintendo 64 emulator] |
[https://ibb.co/rpH9bVR Screenshot of Nintendo 64 emulator] |
||
=={{header|МК-61/52}}== |
=={{header|МК-61/52}}== |
||
<lang>1 2 3 4 С/П БП 00</ |
<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}}== |
||
< |
<syntaxhighlight lang="modula2">LOOP |
||
InOut.WriteString ("SPAM"); |
InOut.WriteString ("SPAM"); |
||
InOut.WriteLn |
InOut.WriteLn |
||
END;</ |
END;</syntaxhighlight> |
||
=={{header|Modula-3}}== |
=={{header|Modula-3}}== |
||
< |
<syntaxhighlight lang="modula3">LOOP |
||
IO.Put("SPAM\n"); |
IO.Put("SPAM\n"); |
||
END;</ |
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}}== |
||
< |
<syntaxhighlight lang="montilang">WHILE TRUE |
||
|SPAM| PRINT . |
|SPAM| PRINT . |
||
ENDWHILE</ |
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}}== |
||
< |
<syntaxhighlight lang="moo">while (1) |
||
player:tell("SPAM"); |
player:tell("SPAM"); |
||
endwhile</ |
endwhile</syntaxhighlight> |
||
=={{header|MUMPS}}== |
=={{header|MUMPS}}== |
||
<syntaxhighlight lang="mumps"> |
|||
<lang MUMPS> |
|||
FOR WRITE "SPAM",! |
FOR WRITE "SPAM",! |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Nanoquery}}== |
=={{header|Nanoquery}}== |
||
< |
<syntaxhighlight lang="nanoquery">while true |
||
println "SPAM" |
println "SPAM" |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |
||
< |
<syntaxhighlight lang="nemerle">while (true) WriteLine("SPAM");</syntaxhighlight> |
||
Or, using recursion: |
Or, using recursion: |
||
< |
<syntaxhighlight lang="nemerle">def loop() : void |
||
{ |
{ |
||
WriteLine("SPAM"); |
WriteLine("SPAM"); |
||
loop(); |
loop(); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|NetRexx}}== |
=={{header|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,467: | Line 1,467: | ||
say 'SPAM' |
say 'SPAM' |
||
end spam |
end spam |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|NewLISP}}== |
=={{header|NewLISP}}== |
||
< |
<syntaxhighlight lang="newlisp">(while (println "SPAM"))</syntaxhighlight> |
||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
< |
<syntaxhighlight lang="nim">while true: |
||
echo "SPAM"</ |
echo "SPAM"</syntaxhighlight> |
||
=={{header|NS-HUBASIC}}== |
=={{header|NS-HUBASIC}}== |
||
Using <code>FOR</code>: |
Using <code>FOR</code>: |
||
< |
<syntaxhighlight lang="ns-hubasic">10 FOR I=0 TO 1 STEP 0 |
||
20 PRINT "SPAM" |
20 PRINT "SPAM" |
||
30 NEXT</ |
30 NEXT</syntaxhighlight> |
||
Using <code>GOTO</code>: |
Using <code>GOTO</code>: |
||
< |
<syntaxhighlight lang="ns-hubasic">10 PRINT "SPAM" |
||
20 GOTO 10</ |
20 GOTO 10</syntaxhighlight> |
||
Using <code>RUN</code>: |
Using <code>RUN</code>: |
||
< |
<syntaxhighlight lang="ns-hubasic">10 PRINT "SPAM" |
||
20 RUN</ |
20 RUN</syntaxhighlight> |
||
=={{header|Oberon-2}}== |
=={{header|Oberon-2}}== |
||
< |
<syntaxhighlight lang="oberon2"> |
||
MODULE InfiniteLoop; |
MODULE InfiniteLoop; |
||
IMPORT |
IMPORT |
||
Line 1,500: | Line 1,500: | ||
END |
END |
||
END InfiniteLoop. |
END InfiniteLoop. |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Objeck}}== |
=={{header|Objeck}}== |
||
< |
<syntaxhighlight lang="objeck"> |
||
while(true) { |
while(true) { |
||
"SPAM"->PrintLine(); |
"SPAM"->PrintLine(); |
||
}; |
}; |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
< |
<syntaxhighlight lang="ocaml">while true do |
||
print_endline "SPAM" |
print_endline "SPAM" |
||
done</ |
done</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="ocaml">let rec inf_loop() = |
||
print_endline "SPAM"; |
print_endline "SPAM"; |
||
inf_loop() |
inf_loop() |
||
in |
in |
||
inf_loop()</ |
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}}== |
||
< |
<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) |
||
:</ |
:</syntaxhighlight> |
||
=={{header|Octave}}== |
=={{header|Octave}}== |
||
< |
<syntaxhighlight lang="octave">while(1) |
||
disp("SPAM") |
disp("SPAM") |
||
endwhile</ |
endwhile</syntaxhighlight> |
||
=={{header|Oforth}}== |
=={{header|Oforth}}== |
||
< |
<syntaxhighlight lang="oforth">begin "SPAM" . again</syntaxhighlight> |
||
=={{header|Ol}}== |
=={{header|Ol}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
(let loop () |
(let loop () |
||
(display "SPAM") |
(display "SPAM") |
||
(loop)) |
(loop)) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|OPL}}== |
=={{header|OPL}}== |
||
< |
<syntaxhighlight lang="opl">PROC main: |
||
LOCAL loop% |
LOCAL loop% |
||
loop%=1 |
loop%=1 |
||
Line 1,554: | Line 1,554: | ||
PRINT "SPAM" |
PRINT "SPAM" |
||
ENDWH |
ENDWH |
||
ENDP</ |
ENDP</syntaxhighlight> |
||
=={{header|Oz}}== |
=={{header|Oz}}== |
||
< |
<syntaxhighlight lang="oz">for do |
||
{Show 'SPAM'} |
{Show 'SPAM'} |
||
end</ |
end</syntaxhighlight> |
||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
< |
<syntaxhighlight lang="parigp">while(1, |
||
print("SPAM") |
print("SPAM") |
||
);</ |
);</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 |
<syntaxhighlight lang="parigp">until(print('SPAM),)</syntaxhighlight> |
||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
< |
<syntaxhighlight lang="pascal">while true do |
||
writeln('SPAM');</ |
writeln('SPAM');</syntaxhighlight> |
||
Alternatively: |
Alternatively: |
||
< |
<syntaxhighlight lang="pascal">repeat |
||
writeln('SPAM') |
writeln('SPAM') |
||
until false;</ |
until false;</syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl">while(1){ |
||
print "SPAM\n"; |
print "SPAM\n"; |
||
}</ |
}</syntaxhighlight> |
||
or equivalently |
or equivalently |
||
< |
<syntaxhighlight lang="perl">print "SPAM\n" while 1;</syntaxhighlight> |
||
=={{header|Phix}}== |
=={{header|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> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
=={{header|PHP}}== |
=={{header|PHP}}== |
||
< |
<syntaxhighlight lang="php">while(1) |
||
echo "SPAM\n";</ |
echo "SPAM\n";</syntaxhighlight> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
< |
<syntaxhighlight lang="picolisp">(loop (prinl "SPAM"))</syntaxhighlight> |
||
=={{header|Pike}}== |
=={{header|Pike}}== |
||
< |
<syntaxhighlight lang="pike"> |
||
while(1) |
while(1) |
||
write("SPAM\n"); |
write("SPAM\n"); |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|PILOT}}== |
=={{header|PILOT}}== |
||
< |
<syntaxhighlight lang="pilot">*TypeSpam |
||
type:SPAM |
type:SPAM |
||
jump:*TypeSpam</ |
jump:*TypeSpam</syntaxhighlight> |
||
=={{header|Pixilang}}== |
=={{header|Pixilang}}== |
||
< |
<syntaxhighlight lang="pixilang">start: |
||
fputs("SPAM\n") |
fputs("SPAM\n") |
||
go start</ |
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;</ |
end;</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. |
||
< |
<syntaxhighlight lang="plainenglish">To run: |
||
Start up. |
Start up. |
||
Write SPAM forever. |
Write SPAM forever. |
||
Line 1,633: | Line 1,633: | ||
To write SPAM forever: |
To write SPAM forever: |
||
Write "SPAM" to the console. |
Write "SPAM" to the console. |
||
Repeat.</ |
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>". |
||
< |
<syntaxhighlight lang="tex">\newlinechar`\^^J |
||
\def\spam{\message{SPAM^^J}\spam}% |
\def\spam{\message{SPAM^^J}\spam}% |
||
\spam</ |
\spam</syntaxhighlight> |
||
=={{header|Pop11}}== |
=={{header|Pop11}}== |
||
< |
<syntaxhighlight lang="pop11">while true do |
||
printf('SPAM', '%p\n'); |
printf('SPAM', '%p\n'); |
||
endwhile;</ |
endwhile;</syntaxhighlight> |
||
=={{header|PostScript}}== |
=={{header|PostScript}}== |
||
simple infinite loop: |
simple infinite loop: |
||
<lang |
<syntaxhighlight lang="postscript">{}loop</syntaxhighlight> |
||
A bit more complex infinite loop: |
A bit more complex infinite loop: |
||
< |
<syntaxhighlight lang="postscript">/go { |
||
/spam |
/spam |
||
{ (SPAM\n) print flush } |
{ (SPAM\n) print flush } |
||
Line 1,661: | Line 1,661: | ||
%start spamming! |
%start spamming! |
||
go</ |
go</syntaxhighlight> |
||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
< |
<syntaxhighlight lang="powershell">for () { |
||
"SPAM" |
"SPAM" |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Prolog}}== |
=={{header|Prolog}}== |
||
< |
<syntaxhighlight lang="prolog">repeat, write('SPAM'), nl, fail.</syntaxhighlight> |
||
=={{header|Pure Data}}== |
=={{header|Pure Data}}== |
||
Line 1,675: | Line 1,675: | ||
Screenshot: https://i.imgur.com/IrwaafZ.png |
Screenshot: https://i.imgur.com/IrwaafZ.png |
||
< |
<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,682: | Line 1,682: | ||
#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;</ |
#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,688: | Line 1,688: | ||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
===Repeat/Forever=== |
===Repeat/Forever=== |
||
< |
<syntaxhighlight lang="purebasic">Repeat |
||
PrintN("SPAM") |
PrintN("SPAM") |
||
ForEver</ |
ForEver</syntaxhighlight> |
||
===Goto=== |
===Goto=== |
||
< |
<syntaxhighlight lang="purebasic">PrintIt: |
||
PrintN("SPAM") |
PrintN("SPAM") |
||
Goto PrintIt</ |
Goto PrintIt</syntaxhighlight> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
In Python 2: |
In Python 2: |
||
< |
<syntaxhighlight lang="python">while 1: |
||
print "SPAM"</ |
print "SPAM"</syntaxhighlight> |
||
In python 3: |
In python 3: |
||
< |
<syntaxhighlight lang="python">while 1: |
||
print("SPAM")</ |
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,713: | Line 1,713: | ||
=={{header|Quackery}}== |
=={{header|Quackery}}== |
||
< |
<syntaxhighlight lang="quackery">[ say "SPAM" cr again ]</syntaxhighlight> |
||
=={{header|R}}== |
=={{header|R}}== |
||
Line 1,719: | Line 1,719: | ||
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. |
||
< |
<syntaxhighlight lang="r">repeat print("SPAM")</syntaxhighlight> |
||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
< |
<syntaxhighlight lang="racket"> |
||
#lang racket |
#lang racket |
||
Line 1,736: | Line 1,736: | ||
(for ([i (in-naturals)]) |
(for ([i (in-naturals)]) |
||
(displayln "SPAM")) |
(displayln "SPAM")) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
Line 1,742: | Line 1,742: | ||
{{works with|Rakudo Star|2010.08}} |
{{works with|Rakudo Star|2010.08}} |
||
<lang |
<syntaxhighlight lang="raku" line>loop { |
||
say 'SPAM'; |
say 'SPAM'; |
||
}</ |
}</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 |
<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</ |
map {say "SPAM"}, ^Inf; # upto operator</syntaxhighlight> |
||
=={{header|Rapira}}== |
=={{header|Rapira}}== |
||
< |
<syntaxhighlight lang="rapira">while 1 do |
||
output: "SPAM" |
output: "SPAM" |
||
od</ |
od</syntaxhighlight> |
||
=={{header|REBOL}}== |
=={{header|REBOL}}== |
||
< |
<syntaxhighlight lang="rebol">forever [print "SPAM"]</syntaxhighlight> |
||
=={{header|Red}}== |
=={{header|Red}}== |
||
< |
<syntaxhighlight lang="red">forever [ |
||
print "SPAM" |
print "SPAM" |
||
]</ |
]</syntaxhighlight> |
||
=={{header|ReScript}}== |
=={{header|ReScript}}== |
||
< |
<syntaxhighlight lang="rescript">while true { |
||
Js.log("SPAM") |
Js.log("SPAM") |
||
}</ |
}</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="rescript">let rec inf_loop = () => { |
||
Js.log("SPAM") |
Js.log("SPAM") |
||
inf_loop() |
inf_loop() |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Retro}}== |
=={{header|Retro}}== |
||
< |
<syntaxhighlight lang="retro">[ "SPAM\n" puts -1 ] while</syntaxhighlight> |
||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
===simple=== |
===simple=== |
||
< |
<syntaxhighlight lang="rexx">/*REXX program displays the word SPAM forever. */ |
||
do forever |
do forever |
||
Line 1,786: | Line 1,786: | ||
end /*DO forever*/ |
end /*DO forever*/ |
||
/*control will never reach here. */ |
/*control will never reach here. */ |
||
/*don't stick a fork in it. */</ |
/*don't stick a fork in it. */</syntaxhighlight> |
||
===esoteric=== |
===esoteric=== |
||
< |
<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,795: | Line 1,795: | ||
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. */</ |
/*don't stick a fork in it. */</syntaxhighlight> |
||
===GO TO version=== |
===GO TO version=== |
||
< |
<syntaxhighlight lang="rexx">/*REXX program displays the word SPAM forever. */ |
||
tell_it: say 'SPAM' |
tell_it: say 'SPAM' |
||
Line 1,804: | Line 1,804: | ||
/*control will never reach here. */ |
/*control will never reach here. */ |
||
/*don't stick a fork in it. */</ |
/*don't stick a fork in it. */</syntaxhighlight> |
||
===too clever by half=== |
===too clever by half=== |
||
< |
<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,812: | Line 1,812: | ||
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. */</ |
/*don't stick a fork in it. */</syntaxhighlight> |
||
=={{header|Ring}}== |
=={{header|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: |
||
< |
<syntaxhighlight lang="robotic"> |
||
: "infinite_loop" |
: "infinite_loop" |
||
* "SPAM" |
* "SPAM" |
||
goto "infinite_loop" |
goto "infinite_loop" |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<syntaxhighlight lang="ruby">loop {puts "SPAM"} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Run BASIC}}== |
=={{header|Run BASIC}}== |
||
< |
<syntaxhighlight lang="runbasic">[loop] print "Spam" :goto [loop] |
||
while 1 |
while 1 |
||
print "Spam" |
print "Spam" |
||
wend</ |
wend</syntaxhighlight> |
||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
< |
<syntaxhighlight lang="rust">fn main() { |
||
loop { |
loop { |
||
println!("SPAM"); |
println!("SPAM"); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|S-lang}}== |
=={{header|S-lang}}== |
||
< |
<syntaxhighlight lang="s-lang">forever print("SPAM");</syntaxhighlight> |
||
=={{header|Salmon}}== |
=={{header|Salmon}}== |
||
< |
<syntaxhighlight lang="salmon">while (true) |
||
"SPAM"!;</ |
"SPAM"!;</syntaxhighlight> |
||
=={{header|Sather}}== |
=={{header|Sather}}== |
||
< |
<syntaxhighlight lang="sather">class MAIN is |
||
main is |
main is |
||
loop |
loop |
||
Line 1,861: | Line 1,861: | ||
end; |
end; |
||
end; |
end; |
||
end;</ |
end;</syntaxhighlight> |
||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
< |
<syntaxhighlight lang="scala">while (true) |
||
println("SPAM")</ |
println("SPAM")</syntaxhighlight> |
||
=={{header|Scheme}}== |
=={{header|Scheme}}== |
||
< |
<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: |
||
< |
<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</ |
end</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>SPAM |
<pre>SPAM |
||
Line 1,889: | Line 1,889: | ||
=={{header|sed}}== |
=={{header|sed}}== |
||
< |
<syntaxhighlight lang="sed">:loop |
||
s/.*/SPAM/ |
s/.*/SPAM/ |
||
p |
p |
||
t loop</ |
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}}== |
||
< |
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i"; |
||
const proc: main is func |
const proc: main is func |
||
Line 1,904: | Line 1,904: | ||
writeln("SPAM"); |
writeln("SPAM"); |
||
end while; |
end while; |
||
end func;</ |
end func;</syntaxhighlight> |
||
=={{header|Self}}== |
=={{header|Self}}== |
||
<lang |
<syntaxhighlight lang="self">['SPAM' printLine] loop</syntaxhighlight> |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
< |
<syntaxhighlight lang="ruby">loop { say "SPAM!" };</syntaxhighlight> |
||
=={{header|Slate}}== |
=={{header|Slate}}== |
||
<lang |
<syntaxhighlight lang="slate">[inform: 'SPAM'] loop</syntaxhighlight> |
||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
< |
<syntaxhighlight lang="smalltalk">[ |
||
Transcript showCR:'boring stuff'. |
Transcript showCR:'boring stuff'. |
||
] loop |
] loop |
||
Line 1,930: | Line 1,930: | ||
[ |
[ |
||
Transcript showCR:'please press CTRL-c!'. |
Transcript showCR:'please press CTRL-c!'. |
||
] doWhile:[true]</ |
] doWhile:[true]</syntaxhighlight> |
||
=={{header|SNOBOL4}}== |
=={{header|SNOBOL4}}== |
||
< |
<syntaxhighlight lang="snobol">loop output = "SPAM" :(loop) |
||
end</ |
end</syntaxhighlight> |
||
=={{header|SNUSP}}== |
=={{header|SNUSP}}== |
||
< |
<syntaxhighlight lang="snusp">@\>@\>@\>@\>++++++++++===!/ < < < < \ |
||
| | | \M=@@@@+@+++++# \.>.>.>.>./ |
| | | \M=@@@@+@+++++# \.>.>.>.>./ |
||
| | \A=@@+@@@@+++# |
| | \A=@@+@@@@+++# |
||
| \P=@@+@@+@@+++# |
| \P=@@+@@+@@+++# |
||
\S=@@+@+@@@+++#</ |
\S=@@+@+@@@+++#</syntaxhighlight> |
||
=={{header|Sparkling}}== |
=={{header|Sparkling}}== |
||
< |
<syntaxhighlight lang="sparkling">while true { |
||
print("SPAM"); |
print("SPAM"); |
||
}</ |
}</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="sparkling">do { |
||
print("SPAM"); |
print("SPAM"); |
||
} while true;</ |
} while true;</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="sparkling">for var b = true; b; b = true { |
||
printf("SPAM\n"); |
printf("SPAM\n"); |
||
}</ |
}</syntaxhighlight> |
||
etc. |
etc. |
||
Line 1,967: | Line 1,967: | ||
{{works with|HomeSpun}} |
{{works with|HomeSpun}} |
||
{{works with|OpenSpin}} |
{{works with|OpenSpin}} |
||
< |
<syntaxhighlight lang="spin">con |
||
_clkmode = xtal1 + pll16x |
_clkmode = xtal1 + pll16x |
||
_clkfreq = 80_000_000 |
_clkfreq = 80_000_000 |
||
Line 1,982: | Line 1,982: | ||
waitcnt(_clkfreq + cnt) |
waitcnt(_clkfreq + cnt) |
||
ser.stop |
ser.stop |
||
cogstop(0)</ |
cogstop(0)</syntaxhighlight> |
||
=={{header|SPL}}== |
=={{header|SPL}}== |
||
< |
<syntaxhighlight lang="spl">> |
||
#.output("SPAM") |
#.output("SPAM") |
||
<</ |
<</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: |
||
< |
<syntaxhighlight lang="sql pl"> |
||
--#SET TERMINATOR @ |
--#SET TERMINATOR @ |
||
Line 2,003: | Line 2,003: | ||
END WHILE; |
END WHILE; |
||
END @ |
END @ |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 2,025: | Line 2,025: | ||
=={{header|Standard ML}}== |
=={{header|Standard ML}}== |
||
< |
<syntaxhighlight lang="sml">while true do |
||
print "SPAM\n";</ |
print "SPAM\n";</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="sml">let |
||
fun inf_loop () = ( |
fun inf_loop () = ( |
||
print "SPAM\n"; |
print "SPAM\n"; |
||
Line 2,037: | Line 2,037: | ||
in |
in |
||
inf_loop () |
inf_loop () |
||
end</ |
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 2,043: | Line 2,043: | ||
=={{header|Stata}}== |
=={{header|Stata}}== |
||
< |
<syntaxhighlight lang="stata">while 1 { |
||
display "SPAM" |
display "SPAM" |
||
}</ |
}</syntaxhighlight> |
||
=== Mata === |
=== Mata === |
||
< |
<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: |
||
< |
<syntaxhighlight lang="stata">for (;1;) printf("SPAM\n")</syntaxhighlight> |
||
=={{header|Swift}}== |
=={{header|Swift}}== |
||
< |
<syntaxhighlight lang="swift">while true { |
||
println("SPAM") |
println("SPAM") |
||
}</ |
}</syntaxhighlight> |
||
=={{header|SystemVerilog}}== |
=={{header|SystemVerilog}}== |
||
< |
<syntaxhighlight lang="systemverilog">program main; |
||
initial forever $display("SPAM"); |
initial forever $display("SPAM"); |
||
endprogram |
endprogram |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Tailspin}}== |
=={{header|Tailspin}}== |
||
< |
<syntaxhighlight lang="tailspin"> |
||
1 -> \( |
1 -> \( |
||
<> 'SPAM$#10;' -> !OUT::write |
<> 'SPAM$#10;' -> !OUT::write |
||
1 -> # |
1 -> # |
||
\) -> !VOID |
\) -> !VOID |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
< |
<syntaxhighlight lang="tcl">while true { |
||
puts SPAM |
puts SPAM |
||
} |
} |
||
Line 2,081: | Line 2,081: | ||
for {} 1 {} { |
for {} 1 {} { |
||
puts SPAM |
puts SPAM |
||
}</ |
}</syntaxhighlight> |
||
=={{header|TI-83 BASIC}}== |
=={{header|TI-83 BASIC}}== |
||
Line 2,087: | Line 2,087: | ||
There are a few ways to achieve this in TI-83 BASIC |
There are a few ways to achieve this in TI-83 BASIC |
||
< |
<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 |
||
< |
<syntaxhighlight lang="ti83b"> |
||
:While 1 |
:While 1 |
||
:Disp "SPAM |
:Disp "SPAM |
||
:End |
:End |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|TI-89 BASIC}}== |
=={{header|TI-89 BASIC}}== |
||
< |
<syntaxhighlight lang="ti89b">Loop |
||
Disp "SPAM" |
Disp "SPAM" |
||
EndLoop</ |
EndLoop</syntaxhighlight> |
||
=={{header|TorqueScript}}== |
=={{header|TorqueScript}}== |
||
< |
<syntaxhighlight lang="torque">While(1) |
||
echo("SPAM");</ |
echo("SPAM");</syntaxhighlight> |
||
=={{header|Transact-SQL}}== |
=={{header|Transact-SQL}}== |
||
< |
<syntaxhighlight lang="sql">WHILE 1=1 BEGIN |
||
PRINT "SPAM" |
PRINT "SPAM" |
||
END</ |
END</syntaxhighlight> |
||
=={{header|Trith}}== |
=={{header|Trith}}== |
||
< |
<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. |
||
< |
<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,133: | Line 2,133: | ||
Use any of these loops: |
Use any of these loops: |
||
< |
<syntaxhighlight lang="bash">while :; do echo SPAM; done</syntaxhighlight> |
||
< |
<syntaxhighlight lang="bash">while true; do echo "SPAM"; done</syntaxhighlight> |
||
< |
<syntaxhighlight lang="bash">until false; do echo "SPAM"; done</syntaxhighlight> |
||
{{works with|bash}} |
{{works with|bash}} |
||
Line 2,143: | Line 2,143: | ||
{{works with|zsh}} |
{{works with|zsh}} |
||
< |
<syntaxhighlight lang="bash">for ((;;)); do echo "SPAM"; done</syntaxhighlight> |
||
==={{header|C Shell}}=== |
==={{header|C Shell}}=== |
||
< |
<syntaxhighlight lang="bash">while (1) |
||
echo SPAM |
echo SPAM |
||
end</ |
end</syntaxhighlight> |
||
==={{header|es}}=== |
==={{header|es}}=== |
||
<lang |
<syntaxhighlight lang="es">forever {echo SPAM}</syntaxhighlight> |
||
=={{header|UnixPipes}}== |
=={{header|UnixPipes}}== |
||
<lang |
<syntaxhighlight lang="bash">yes SPAM</syntaxhighlight> |
||
=={{header|Unlambda}}== |
=={{header|Unlambda}}== |
||
< |
<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}} |
||
< |
<syntaxhighlight lang="ursa">while true |
||
out "SPAM" endl console |
out "SPAM" endl console |
||
end while</ |
end while</syntaxhighlight> |
||
=={{header|V}}== |
=={{header|V}}== |
||
< |
<syntaxhighlight lang="v">true [ |
||
'SPAM' puts |
'SPAM' puts |
||
] while</ |
] while</syntaxhighlight> |
||
=={{header|Vala}}== |
=={{header|Vala}}== |
||
< |
<syntaxhighlight lang="vala">for(;;) stdout.printf("SPAM\n");</syntaxhighlight> |
||
< |
<syntaxhighlight lang="vala">while(true) stdout.printf("SPAM\n");</syntaxhighlight> |
||
< |
<syntaxhighlight lang="vala">do stdout.printf("SPAM\n"); while(true);</syntaxhighlight> |
||
=={{header|VAX Assembly}}== |
=={{header|VAX Assembly}}== |
||
< |
<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,185: | Line 2,185: | ||
F5 11 0015 8 brb loop ;forever |
F5 11 0015 8 brb loop ;forever |
||
0017 9 |
0017 9 |
||
0017 10 .end main</ |
0017 10 .end main</syntaxhighlight> |
||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
< |
<syntaxhighlight lang="vb">Do |
||
Debug.Print "SPAM" |
Debug.Print "SPAM" |
||
Loop</ |
Loop</syntaxhighlight> |
||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
< |
<syntaxhighlight lang="vb">Do |
||
WScript.Echo("SPAM") |
WScript.Echo("SPAM") |
||
Loop</ |
Loop</syntaxhighlight> |
||
=={{header|Vedit macro language}}== |
=={{header|Vedit macro language}}== |
||
< |
<syntaxhighlight lang="vedit">while (1) { |
||
Message("Spam\n") |
Message("Spam\n") |
||
}</ |
}</syntaxhighlight> |
||
or: |
or: |
||
< |
<syntaxhighlight lang="vedit">do { |
||
Message("Spam\n") |
Message("Spam\n") |
||
} while (1)</ |
} while (1)</syntaxhighlight> |
||
or: |
or: |
||
< |
<syntaxhighlight lang="vedit">for (;1;) { |
||
Message("Spam\n") |
Message("Spam\n") |
||
}</ |
}</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: |
||
< |
<syntaxhighlight lang="vedit">Repeat (ALL) { |
||
Message("Spam\n") |
Message("Spam\n") |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Visual Basic}}== |
=={{header|Visual Basic}}== |
||
< |
<syntaxhighlight lang="vb">Do |
||
Debug.Print("SPAM") |
Debug.Print("SPAM") |
||
Loop</ |
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+}} |
||
< |
<syntaxhighlight lang="vbnet">Do |
||
Console.WriteLine("SPAM") |
Console.WriteLine("SPAM") |
||
Loop</ |
Loop</syntaxhighlight> |
||
=={{header|Vlang}}== |
=={{header|Vlang}}== |
||
< |
<syntaxhighlight lang="vlang">fn main() { |
||
for { |
for { |
||
print("SPAM\n") |
print("SPAM\n") |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Wart}}== |
=={{header|Wart}}== |
||
< |
<syntaxhighlight lang="wart">repeat :forever |
||
prn "spam"</ |
prn "spam"</syntaxhighlight> |
||
=={{header|Wee Basic}}== |
=={{header|Wee Basic}}== |
||
< |
<syntaxhighlight lang="wee basic">let loop=1 |
||
while loop=1 |
while loop=1 |
||
print 1 "SPAM" |
print 1 "SPAM" |
||
wend |
wend |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Whenever}}== |
=={{header|Whenever}}== |
||
< |
<syntaxhighlight lang="whenever"> |
||
1 print("SPAM"); |
1 print("SPAM"); |
||
1; |
1; |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
< |
<syntaxhighlight lang="ecmascript">while (true) System.print("SPAM")</syntaxhighlight> |
||
=={{header|X86 Assembly}}== |
=={{header|X86 Assembly}}== |
||
{{works with|NASM|Linux}} |
{{works with|NASM|Linux}} |
||
< |
<syntaxhighlight lang="asm"> |
||
section .text |
section .text |
||
global _start |
global _start |
||
Line 2,272: | Line 2,272: | ||
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: |
||
< |
<syntaxhighlight lang="lisp">(defun keep-printing-spam () |
||
(while t |
(while t |
||
(display "SPAM") |
(display "SPAM") |
||
(newline) ) )</ |
(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. |
||
< |
<syntaxhighlight lang="lisp">(defun keep-printing-spam () |
||
(display "SPAM") |
(display "SPAM") |
||
(newline) |
(newline) |
||
(keep-printing-spam) )</ |
(keep-printing-spam) )</syntaxhighlight> |
||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
< |
<syntaxhighlight lang="xpl0">code Text=12; |
||
loop Text(0, "SPAM |
loop Text(0, "SPAM |
||
")</ |
")</syntaxhighlight> |
||
=={{header|Z80 Assembly}}== |
=={{header|Z80 Assembly}}== |
||
Line 2,295: | Line 2,295: | ||
Using the Amstrad CPC firmware: |
Using the Amstrad CPC firmware: |
||
< |
<syntaxhighlight lang="z80">org $4000 |
||
txt_output: equ $bb5a |
txt_output: equ $bb5a |
||
Line 2,308: | Line 2,308: | ||
jr print |
jr print |
||
spam: defm "SPAM\r\n\0"</ |
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 { |
pub fn main() !void { |
||
Line 2,317: | Line 2,317: | ||
while (true) try stdout_wr.writeAll("SPAM\n"); |
while (true) try stdout_wr.writeAll("SPAM\n"); |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
< |
<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</ |
fcn{ println("SPAM"); return(self.fcn()) }(); // tail recursive lambda</syntaxhighlight> |
||
{{omit from|GUISS}} |
{{omit from|GUISS}} |
||
Line 2,330: | Line 2,330: | ||
=={{header|Zoomscript}}== |
=={{header|Zoomscript}}== |
||
For typing: |
For typing: |
||
< |
<syntaxhighlight lang="zoomscript">var loop |
||
loop = 1 |
loop = 1 |
||
while ne loop 0 |
while ne loop 0 |
||
print "SPAM" |
print "SPAM" |
||
println |
println |
||
endwhile</ |
endwhile</syntaxhighlight> |
||
For importing: |
For importing: |
||