Gott

From Esolang
Jump to navigation Jump to search

Gott is an esoteric programming language that uses only for loops. It stores memory only as non-nested arrays of 4-bytes integers.

Syntax/Functions

Gott programs are ASCII text files, formatted in lines. Each line can begin with one of several built-in functions, a memory reassignment, or a looping structure. All built-in functions are lowercase and often abbreviations of their functions. The following is a complete list of all built-in functions and their usage.

Function Description
print Prints the rest of the line as ASCII text. Does not print the following newline.
printnum Prints out the computed value of its argument, which can be a variable or an expression evaluating to a number.
newln Prints a newline character, \n.
exit Simulates an EOF for use in interactive mode.
def Reserves memory for and defines the value of a variable.
range Returns a series of integers from its first argument to its second.
= Used to separate the address of a block of memory and the value to be assigned there (e.g, x[0] = 5).

Variables

Every variable is an array of 4-byte integers. The variable's size must be declared at the time it is reserved, and cannot be changed. A variable can also be an array with only one item, in which cane no index is required. Variables can be indexed from the start with numbers 0 and greater, and from the back with any negative number. For example,

array[3]

in a 10-place array would be item 4 of the array (indexing from 0).

array[-3]

would be the length of the array minus the index: item 8 of the array.

Variables can be declared and reassigned as follows:

def var[5] 1, 0, 0, 0, 0
var[2] = 4*var[0] + 1 # 1, 0, 3, 0, 0

Note: + and - must preceded and followed by spaces.

Control Flow

The only flow control utility is a for loop, which can be implemented in two different ways. Given an array Z, here are the two kinds of for loops:

for(Z): # Repeats the following indented block for the number of times in the first position of x.
for(i in Z): # Repeats the following indented block iterating i along each member of Z until the end of Z is reached.

Example Programs

Hello World

print Hello, World!
newln

99 Bottles of Beer

print 99 bottles of beer on the wall,
newln
print 99 bottles of beer.
newln
print Take one down, pass it around,
newln
decl values[98] range 98, 1
for(bottles in values):
	printnum bottles
	print  bottles of beer on the wall.
	newln
	printnum bottles
	print  bottles of beer on the wall,
	newln
	printnum bottles
	print  bottles of beer.
	newln
	print Take one down, pass it around,
	newln
print no more bottles of beer on the wall.
newln