Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
- Ada
- C
- C
- C
- C
- Clojure
- Cobol
- C++
- C++
- C#
- D
- D
- Dart
- Dart
- Elixir
- Erlang
- Fortran
- Go
- Groovy
- Haskell
- Haskell
- Haskell
- JS
- JS
- Java
- Java
- Java
- Java
- Java
- Kotlin
- Lisp
- Lisp
- Lisp
- Lua
- Lua
- Lua
- Obj-C
- PHP
- Pascal
- Pascal
- Perl
- Perl
- Prolog
- Prolog
- Prolog
- Python
- Python
- Ruby
- Rust
- Scala
- Scheme
- Smalltalk
- VB
loop
null;
end loop;
null; means "do nothing"
while(1){
// Do something
}
You may remove the curly braces if the block is only 1 instruction.
loop:
goto loop;
for(;;){
// Do something
}
You may remove the curly braces if the block is only 1 instruction.
(loop []
;; do something
(recur))
IDENTIFICATION DIVISION.
PROGRAM-ID. no end loop.
PROCEDURE DIVISION.
PERFORM UNTIL 1 < 0
DISPLAY "Something"
END-PERFORM
STOP RUN.
while (true) {
// Do something
}
You may remove the curly braces if the block is only 1 instruction.
The compiler might warn you that the loop expression is never false.
Warning: infinite loop without side-effects is undefined behaviour.
The compiler might warn you that the loop expression is never false.
Warning: infinite loop without side-effects is undefined behaviour.
for (;;) {
/// Do something
}
You may remove the curly braces if the block is only 1 instruction.
Warning: infinite loop without side-effects is undefined behaviour.
Warning: infinite loop without side-effects is undefined behaviour.
while (true)
{
// Do something
}
for (;;) {}
the while form is actually lowered to this one.
while (true) { }
while (true) {
// do something
}
for (;;) {
}
defmodule Looping do
def infinite do
# Write code here
infinite
end
end
loop() ->
do:something(),
loop().
do
end do
for {
// Do something
}
No need to write loop variables nor end condition.
let x = x in x
x will be defined as itself, and recurse infinitely when evaluated
for(;;) {
console.log('Oops')
}
while (true) {
// to infinity
}
while (true);
for (;;);
do {} while (true);
for(;;){
// Do something
}
The three expressions in the for clause (initialization, termination, increment) are left empty.
while(true) {
// Do something
}
(loop)
(defun infinite-loop (x)
(apply x (infinite-loop x)))
Not exactly the same as the original since that was in scheme and this is Common Lisp but it infinitely loops until the control stack is exhausted.
(do () (nil)
(write-line "Control-C to quit this infinite loop")
(sleep 1))
Kill the Lisp process to exit.
DO is the most general kind of loop, supporting local variables and complex iteration logic.
A common alternative is "(LOOP)", but you'll have to learn its non-Lispy syntax.
DO is the most general kind of loop, supporting local variables and complex iteration logic.
A common alternative is "(LOOP)", but you'll have to learn its non-Lispy syntax.
while true do
-- Do something
end
::loop::
goto loop
repeat
until false
for (;;);
Precisely same as plain C
while (true) {
// do something
}
While True do { nothing };
Actual do statements can be omitted by using a semicolon.
The "{ nothing }" part is a comment.
The "{ nothing }" part is a comment.
repeat until false;
say "" while True;
Works in Perl 6
while (1) {
do_stuff();
}
?- repeat, false.
% repeat/0 is built-in, but could be defined like this:
repeat.
repeat :- repeat.
`repeat/0` succeeds an infinite number of times, and each time is immediately foiled by false/0. The default execution strategy just tries clauses in order from left to right so this induces an infinite loop.
loop :- loop.
?- loop.
loop succeeds if loop succeeds, so when we ask the top level if loop succeeds, it proceeds to ask if loop succeeds.
repeat, write("hello\n").
This a bit strange, repeat is a predicate that will always succeed, that is always true.
while 1: ...
while True:
pass
loop do
# endless joy
end
loop {
// Do something
}
while(true){
println(3)
}
(let forever ()
(forever))
Named let infinite loop with no arguments.
[] repeat.
Do
' Do something
Loop