Giter Site home page Giter Site logo

regmachineprolog's Introduction

Register machine interpreter implementation in Prolog

Usage:

?- compute(Registers, Program, Output).

?- computeFromFile(Filename, Registers, Output).

Instructions clauses come in three flavours:

  • inc(R, L) = increment register R's content and jump to instruction labelled L
  • dec(R, L1, L2) = if register R > 0, decrement R's contents and jump to instruction labelled L1, or if R == 0, jump to instruction labelled L2
  • hALT = halts the program. ( halt is a keyword in Prolog so I couldn't use it :C )

The files which can be read as register machine programs are a list of Prolog clauses and are .pl files themselves. For example, a program to compute f(x,y) = x+y addition.pl would be:

dec(1,1,2).
inc(0,0).
dec(2,3,4).
inc(0,2).
hALT.

You can try to search for programs (e.g. compute([0,1], X, [1,0])) but its almost guaranteed to crash or loop forever.

regmachineprolog's People

Contributors

nukeyfox avatar

Stargazers

 avatar

Watchers

James Cloos avatar  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.