# Infinite Goto

Infinite Goto is a language by User:PythonshellDebugwindow. Programs in it will never end.

## Storage

Infinite Goto uses an arbitrarily long array of arbitrarily large unsigned integers. It also uses a cell pointer (CP) to keep track of the current cell.

## Syntax

All valid lines of an Infinite Goto have an integer on them. This integer can’t have any leading zeros or start with a plus sign (+). Invalid or empty lines cause the program to go to the next line (or line 0 if out-of-range), so all valid Infinite Goto programs match the following regex: `-?([1-9][0-9]*|0)(\n-?([1-9][0-9]*|0))*`. It’s considered good practice to put negative numbers on unused lines, e.g. if you skip line 5 you should put a negative number such as -5. Integers less than 0 are treated as 0, and integers greater than or equal to the program's length are treated as the program's length minus 1. The IP then jumps to the (0-based) Nth line, where N is the integer on the current line after the previously mentioned modifications have been applied. For example,

```1
0
```

would jump infinitely between lines 0 and 1,

```0
```

```3
-1
```

would jump to line 3, find the last line is line 1, then jump to line 0 because of overflow, and repeat this forever. Jumping to certain lines has special effects:

Line Number (0-based) Effect
5 Sets the current cell to user input as a base-10 integer, if invalid then sets it to 0
8 Decrements the current cell if it's greater than 0
10 Increments the CP
13 Decrements the CP
16 Outputs the current cell’s value as a base-10 integer, with a newline
19 Jumps to line 20 if the current cell is greater then 0, else jumps to line 21
27 Jumps to a random line 28-32 both inclusive (the number on this line is ignored but should still be valid, if it’s not valid then it jumps to line 28 (or 0 if out-of-range) no matter what)
35 Sets the current cell to the previous line number, e.g. coming from line 7 sets the current cell to 7

All lines that are nonzero multiples of 2 and aren’t listed above (other than 7, an example for 35) (and aren’t one of the above numbers increased by a multiple of 45–see below), when jumped to, will increment the current cell. As well as this, every 45 lines, the modifications apply again, e.g. lines 5, 50, 95, etc. will all set the current cell to user input, lines 8, 53, and 98 do the same thing, and so on, and all these line numbers shown (20, 21, 28, etc.) do the same.

## Examples

### Numeric cat

```5
1
-2
-3
-4
16
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
1
```

This program uses an infinite loop on line 1 (the second line) to effectively “halt” the program.

```5
-1
-2
-3
-4
16
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
5
```

```27
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
35
35
35
35
35
-33
-34
10
36
```

## Resources

• An interpreter written in Python along with some examples