Coder Social home page Coder Social logo

tim's Introduction

tim

This is a computing machine controlled by a 2-dimensional input language. Here's an example (examples/multiply):

v This program multiplies numbers in the first and second register and stores the result in the third register
. This program cannot handle negative numbers. If one of the inputs is negative, the program enters an infinite loop.
.
. Now go through a loop until the first register is 0.
. In the loop:
.       - decrement the first register
.       - add the second register onto the third
.
.   Test the first register here
.   |            Print the third register (the result) and exit
.   |            |
.   v            v
>.[.\............]]dx
.   -
.   >].>.\.]].>.\.[[.v
.      . .    . .    .
.      . .    . .    .
.      . -    . -    .
.      [ ]    ] [    .
.      . +    . .    .
.      [ ]    ] [    .
.      . +    . +    .
.      . .    . .    .
.      ^.<    ^.<    .
.                    .
^....................<

Here's another example. This one prints and decrements the first register until it is zero:

d-\x>
  >.^

There are 10 "tapes". The initial values for the registers on tape 0 are read from standard input (or set to zero if none are provided).

It's written in Python 3. Run machine.py with the argument /path/to/input/file to be amazed.

We can chain multiple programs together, for example:

echo "3 5" | ./machine.py examples/multiply | ./machine.py examples/loop

tim's People

Contributors

laraost avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.