Tock
Every function is a function of time, and each one only sees the others one tick ago.
Silver, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Silver made Tock in 2021. The name is about working in discrete steps; Tick was taken. A program is a set of functions of an integer t. A function may use the values every function had at t-1, its own included, and nothing else, not their values at t, at t-2 or at any fixed t.
Read the story
Two functions are special. The run ends at the first t where halt is 0, and the output is the value of out at that t.
The machine
Each function is written name initial { body }. At t = 0 it has its initial value. At every later step all functions are worked out at once from the values of the step before, so the order they are written in does not matter.
| Body | Means |
|---|---|
expr | The value at t |
a = b : expr; | A clause, tried in order; also != > < >= <= |
otherwise : expr | Taken when no clause before it matched |
Expressions use + - * / % ^ and brackets. A name in an expression is that function's value at t-1, and // starts a comment. When no clause matches, the run stops with an error.
Example
The first example counts halt down from 10 while out counts up.
The first example counts halt down from 10 while out counts up.
The second needs a third function. halt sees counter one step late, so it turns 0 at t = 11, when out holds twice the counter of t = 10.
Patterns it teaches
- Turing completeness: the specification shows it with a translation of Fractran, which this implementation runs with its blanks filled in for the fraction 3/2.
Further
See also
Also in Strange time
Write your own in Run Convert a program from Tock
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: tock.
Command line
shib run tock -e 'halt 10 {
halt - 1
}
out 0 {
out + 1
}'shib manual tockSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/tock.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org