Looping counter

From Esolang
(Redirected from Looping Counter)
Jump to navigation Jump to search

A looping counter counts up to infinity or a specific number (or possibly down to a specific number or negative infinity). Counting from 99 to 0 can be used as a simpler alternative of the 99 bottles of beer program to prove that a language is usable for computation.

The program exhausts unbounded memory over infinite time. It prints each value as it counts, and it exhausts infinite states in infinite time. The program is essentially an unbounded unary counter.


The output of a looping counter is as follows:

*
**
***
****
*****
******
*******
********
*********
**********
***********
************

With each iteration, the memory used grows.

Examples

Befunge

1:v,*25<
  :    :
 v_$1+ ^
 "
 *:
 "-
 ,1
 >^

Brainfuck

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

Stack-based

VAR x
VAR y
VAR z
VAR one
S x 1
S one 1
S z 10
C x y
P "*"
SU y one
JB y 2
OC z
JB one 5

Subleq

42 1 7 0 0 0 0 3 1 10
5 4 13 6 5 16 5 5 19
6 1 28 0 -1 25
5 5 19
4 3 0 9 -1 0 5 5 10

The 42 can be altered to print any character you like.

UTC+8

无限地(重复循环次数次输出“*”然后输出字符10)。

Two examples are available on the page ///, printing rows of increasingly many asterisks with each run.

The looping counter was also used as the first demonstration that Black was possibly Turing-complete. (Although a looping counter does not prove Turing-completeness in its own right, it helps to demonstrate how a language is capable of storing and retrieving arbitrary amounts of data, which is often one of the hardest aspects of Turing-completeness to discover within a language.)