Figurehead
The undeniable sense of wonder / Kicks my head in / Disturbingly unable to escape / I dive to drown ('Figurehead' by Covenant)
- An esoteric programming language.
- Designed in autumn of 2008.
- Author: Keymaker.
- Turing-complete.
- Deterministic.
- Incapable of input/output.
- Two instructions.
- Push into memory.
- Symbolized with "|" (dec 124).
- Always increases memory usage.
- Loop until no more in memory.
- Symbolized with " " (dec 32).
- Always decreases memory usage.
- Programs consist only of "|" and " " characters.
- Only sequences longer than one character are noted.
- Looping sequences may be nested.
- Nested loops must end inside the loop they begin in.
-
- Every loop must have a beginning and an end.
- Same loop sequence may be used more than once.
- Execution always modifies the memory.
- "|" pushes data to right end of memory.
- " " pops data from the right end of memory, and empty memory results in error. If the memory includes at least one instance of the value indicated by the popped value, a loop begins, and one instance of the value is removed from memory, search of it beginning from left and moving to right. As many cycles will follow as there are instances of value in memory. Naturally, it may be the loop is not executed at all, if there are no values.
- The memory is unbounded.
- Figurehead is Turing-complete.
- I've proved this by making a program to translate Minsky Machine programs into Figurehead. As Minsky Machine is Turing-complete, anything that can run all translations of it is Turing-complete as well. Here are the instructions Minsky Machine uses:
- X inc A b, increments the value in register A by one, jumps to instruction b. X is the line/instruction number.
- X dec B c d , if value in register B is zero, jumps to c, otherwise decrements the register value by one, and then jumps to d. X is the line/instruction number.
- X halt, halts the execution. X is, again, the line/instruction number.
- Here is the program: mmfig.py. As input give a Minsky Machine program written with the notation above (line numbers as numbers, register names as A-Z strings, addresses with numbers).
- A sample program, mult.mm, which multiplies a value in register with itself. (In this case 9 with 9.) The program translated into Figurehead using the translator: mult.fig. Once ran with a Figurehead interpreter there should be some value in the memory for 81 times, the amount representing the value.
-
- Programs.
- a.fig - the shortest infinite loop.
- b.fig - example of two inner loops, results there being twelve instances of some value in the memory.
- c.fig - a program to expand the memory infinitely.
- factorial.fig - calculates the factorial of n, which is given as a sequence of "|| " in the very beginning of the program. By default the program will count 7!, which results into 5040 instances of some value in the memory. (Running may take a while.)
- Interpreter.
- figurehead.py - an interpreter written in Python. Should notice erroneous programs pretty well, but as usually, can't promise it notices everything. It's not the fastest possible, either... As the language has no input or output, the interpreter shouldn't print anything as long as there are no errors that halt it. Thus, give an extra argument, for example 'abc', to see the memory state after execution. If you give two extra arguments, the debug mode will be enabled and you can follow the memory states during execution. Running using the debug mode takes much more time than without.
- Etymology:
- Named after an excellent song, from which a verse is quoted on top of the page.
- Also, since a Turing-tarpit like this is to me a small dream come true, in the area of esolangs, it hopefully is a figurehead on my (strictly metaphorical) ship as I sail towards the ever darker, deeper, and mysterious waters of esoteric programming languages.
- And it sounds quite impressive, no? :)
-- Keymaker, 26.9.2008