@turing-machine-js/library-binary-numbers

1.0.0 • Public • Published

@turing-machine-js/library-binary-numbers

Build Status npm (tag)

A library for the turing-machine-js.

Install

Using npm:

npm install @turing-machine-js/library-binary-numbers

or using yarn:

yarn add @turing-machine-js/library-binary-numbers

A concept

Binary numbers are represented as a sequence of symbols 0 and 1.

A representation of a number starts with symbol ^ and ends with symbol $.

For example:

  • ^$ stands for 0
  • ^1$ stands for 1
  • ^10$ stands for 2
  • ^11$ stands for 3
  • etc.

There is no ability to work with negative numbers at this time.

This library provides following objects to work with binary numbers:

  • getTapeBlock - this function returns a TapeBlock class instance. It has only one tape. An alphabet of the tape contains the following symbols: space as a blank symbol, ^, $, 0 and 1.
  • states - following States class instances which represent some algorithms:
    • goToNumber - move the head to the number's end
    • goToNextNumber - move the head to the next number (to the right)
    • goToPreviousNumber - move the head to the previous number (to the left)
    • deleteNumber - delete the current number
    • goToNumbersStart - move the head to the number's start
    • invertNumber - change every symbol in the number to it's opposite one (0 to 1 and 1 to 0)
    • normalizeNumber - delete leading zeros
    • plusOne - add 1 to the number
    • minusOne - subtract 1 from the number

If you want to use states which were described earlier, you must use a tape block received from the getTapeBlock function.

Links

  • The information about TapeBlock and State classes is here
  • Turing Machine on the Wikipedia

Package Sidebar

Install

npm i @turing-machine-js/library-binary-numbers

Weekly Downloads

1

Version

1.0.0

License

GPL-3.0-or-later

Unpacked Size

43.8 kB

Total Files

5

Last publish

Collaborators

  • mellonis