Gearbox

From Esolang
Jump to navigation Jump to search
Gearbox
Paradigm(s) declarative
Designed by User:Vizdun
Appeared in 2022
Computational class Unknown
Reference implementation gearbox
File extension(s) .gr

Gearbox is an esoteric programming language based on mechanical gears.

Overview

Gearbox code begins with the declaration of the original gear, which will spin all the other gears. The syntax for declaring a gear is xn? where x is the type of the gear, n is the number of teeth of the gear and ? are additional properties a gear might have. For example g12 is a simple gear with 12 teeth.

There are currently three types of gears in gearbox:

Symbol Name Description
g Gear A simple gear.
c Counter A gear which indicates its current rotation.
e Ender A gear which is going to stop the machine, and by extension the program, once it fully rotates.

Connections

There are two ways to connect gears: linear and parallel. Linear connection is a simple arrangement where the driver gear rotates the follower gear. Only two gears are involved in a linear connection. Parallel connection is one where follower gears are placed on the same axis as the driver gear and are therefore rotating with it. There is no limit on how many gears can be in parallel connection.

A follower gear in linear rotates in the oppose direction of its driver gear. Its rotational speed is given by ωf = ωd * ( nd / nf ) where ωf is the rotational speed of the follower gear, ωd is the rotational speed of the driver gear, nd is the number of teeth the driver gear has and nf is the number of teeth the follower gear has.

Follower gears in parallel connection rotate in the same direction as their driver gear. Their rotational speed is the same as their driver gear's rotational speed.

Connection Syntax Examples

Three gears with 12 teeth in a linear connection.

g12g12g12

Three gears with 12 teeth connected in a parallel connection to a gear with 6 teeth.

g6[g12][g12][g12]

Three gears with 12 teeth connected in a parallel connection and a gear with 24 teeth connected in a linear connection to a gear with 6 teeth.

g6[g12][g12][g12]g24

Counter

Counter gear has some additional properties: symbols (required) and label (optional). Symbols are what a counter gear displays as it rotates. Label denotes the group of counter gears a gear belongs to and is displayed alongside it.

A counter gear with 10 teeth, symbols 0-9 and label "Numbers":

c10{"0","1","2","3","4","5","6","7","8","9"}l"Numbers"

Execution Details

By default, the original gear will be rotated as fast as possible, however there is an option to rotate it at a given speed.

It is possible to start the program at a different point in execution by simply starting it with the original gear already being rotated.

Examples

Examples of gearbox code.

Hello World

g1
g1c214{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c375{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c136{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c136{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c107{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c220{" ",".",",","\"","'","-","?",":","!",";"}
g1c1320{" ",".",",","\"","'","-","?",":","!",";"}
g1c68{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c107{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c88{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c136{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c500{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","Y","X","Z"}
g1c73{" ",".",",","\"","'","-","?",":","!",";"}
g1e60

Clock

g43200
g1c60     {"0","1","2","3","4","5"}                                           l"Seconds : "
g1c10     {"0","1","2","3","4","5","6","7","8","9"}                           l"Seconds : "
g1c3600   {"0","1","2","3","4","5"}                                           l"Minutes : "
g1c600    {"0","1","2","3","4","5","6","7","8","9"}                           l"Minutes : "
g1c43200  {"N","I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII"} l"Hours   : "

Counter

g1
g1c1000000{"0","1","2","3","4","5","6","7","8","9"}
g1c100000{"0","1","2","3","4","5","6","7","8","9"}
g1c10000{"0","1","2","3","4","5","6","7","8","9"}
g1c1000{"0","1","2","3","4","5","6","7","8","9"}
g1c100{"0","1","2","3","4","5","6","7","8","9"}
g1c10{"0","1","2","3","4","5","6","7","8","9"}
g1e999999