Skip to content

LitFill/fractran-koka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FRACTRAN Koka

A simple FRACTRAN interpreter written in Koka.

What is FRACTRAN?

FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Conway. A FRACTRAN program is an ordered list of positive fractions, together with an initial positive integer $n$.

The program is run by updating the integer $n$ as follows:

  1. For the first fraction $f$ in the list for which $nf$ is an integer, replace $n$ by $nf$.
  2. Repeat this rule until no fraction in the list, when multiplied by $n$, produces an integer, then halt.

Getting Started

Prerequisites

Installation

Clone the repository:

git clone https://github.com/yourusername/fractran-koka.git
cd fractran-koka

Building and Running

You can run the interpreter using the Koka compiler:

koka src/main.kk -- examples/mul.frac 12

Or build an executable:

koka -o fractran src/main.kk
./fractran examples/mul.frac 12

Examples

The examples/ directory contains some sample FRACTRAN programs:

  • mul.frac: Multiplication program.
  • prime.frac: Conway's prime-generating program.
  • sample.frac: A simple test program.

Project Structure

  • src/: Source code in Koka.
    • fractran.kk: The core FRACTRAN library.
    • main.kk: CLI entry point.
  • examples/: Sample FRACTRAN programs.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Releases

No releases published

Packages

 
 
 

Contributors

Languages