A FRACTRAN language interpreter
FRACTRAN is a Turing-complete esoteric programming language invented by John Conway in 1987. For more information check Wikipedia page and the original paper.
fractran should be compiled and installed using cargo.
In this Section I assume that the reader has basic knowledge about
git and the usage of command line environment.
To compile fractran clone this repository and then build the binary using:.
cargo build --releaseThe executable should be in the target/release directory.
Otherwise you can directly compile and install fractran by running:
cargo install --git https://github.com/FilippoRanza/fractranIn this case cargo will automatically move the executable into
the default installation directory.
If you are on Unix remember to strip the executable. Go
to the directory containing the fractran executable and run:
strip fractranfractran takes its input source code from file given as command line argument.
Running a FRACTRAN program with fractran is very simple, just call:
fractran your-src.fractranYou can always read the help:
fractran --helpA FRACTRAN program is an ordered list of fractions and
an initial value. fractran expects a file written as:
init NUMBER
list FRACTION_LIST
Where FRACTION_LIST is:
FRACTION_LIST := FRACTION FRACTION_LIST | FRACTION
And FRACTION is:
FRACTION := NUMBER NUMBER | NUMBER / NUMBER
The first NUMBER is the numerator, the second is the denominator.
NUMBER is an positive integer number (internally a 128 bit unsigned number).
It is possible to use C style single line and multi line comments.
The following code implements the multiplication.
/*
FRACTRAN multiplication.
*/
init 72 // 72 = 2³ + 3²
list
455 33
11 13
1 11
3 7
11 2
1 3
More examples can be found in the examples directory.