Skip to content

42 school project. Functional implementation of a Turing machine in OCaml.

Notifications You must be signed in to change notification settings

artainmo/ft_turing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_turing

42 school subject.

In OCaml using functional-programming I implemented a single headed and single tape Turing machine from a description provided in json.
The Turing machine is the first mathematical and algorithmic model behind a general purpose computer.

Run

  1. To install all dependencies use make env. We expect you to be on mac with 'brew' available.
  2. Now compile and create the program executable named 'ft_turing'. Use make to compile to byte-code with the 'ocamlc' compiler or use make opt to compile to machine-code with 'ocamlopt'.
  3. To run the Turing machine launch the executbale with as first argument a json file describing a machine and as second argument machine input. For example like this ./ft_turing machines/unary_sub.json "111-11=".

Other commands

Tu clean the compilation file use make fclean.
To clean and compile back use make re or make re_opt.

Tests

  1. ./ft_turing machines/unary_sub.json "111-11=" (should equal "1")
  2. ./ft_turing machines/unary_add.json "11+11111=" (should equal "1111111")
  3. ./ft_turing machines/palindrome_or_not.json 11011 (should equal "y")
  4. ./ft_turing machines/palindrome_or_not.json 1011 (should equal "n")
  5. ./ft_turing machines/0n1n.json 000111 (should equal "y")
  6. ./ft_turing machines/0n1n.json 000 (should equal "n")
  7. ./ft_turing machines/02n.json 0000 (should equal "y")
  8. ./ft_turing machines/02n.json 0 (should equal "n")

Documentation

artainmo - OCaml
Turing Machines Explained - Computerphile
Turing Machine Primer - Computerphile
Busy Beaver Turing Machines - Computerphile
Turing Complete - Computerphile
Turing Machines - How Computer Science Was Created By Accident

About

42 school project. Functional implementation of a Turing machine in OCaml.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published