- 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
(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.
(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.
?- 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.
repeat, write("hello\n").
This a bit strange, repeat is a predicate that will always succeed, that is always true.