0.1.6 • Published 5 years ago
turing-machine-js v0.1.6
turing-machine-js
A convenient Turing machine
This repository contains following packages:
Example
import TuringMachine, {
Alphabet, haltState,
ifOtherSymbol,
movements,
State,
symbolCommands,
Tape
} from '@turing-machine-js/machine';
const alphabet = new Alphabet({
symbolList: ['$', 'a', 'b', 'c'],
});
const tape = new Tape({
alphabet,
symbolList: ['a', 'b', 'c'],
});
const machine = new TuringMachine(tape);
const eraseState = new State({
['abc']: {
symbol: symbolCommands.erase,
movement: movements.right,
},
[ifOtherSymbol]: {
nextState: haltState,
},
});
console.log(tape.symbolList.join('')); // abc
machine.run(eraseState);
console.log(tape.symbolList.join('')) // $$$$