A turing tape is the means by which a turing machine can store information that can be used in a calculation.
A tape consist of
cells: there is an infinite number of them, both to the left and to the right, and each cell can hold a Symbol
a head: that scans a certain cell and can read and write a Symbol to it. The head can also be moved one of the Direction, left and right.
gap> LoadPackage("turing");; gap> tape := TmTape(); <tape empty> gap> TmTapeWrite(tape, TmSymbol('I')); gap> TmTapeHeadLeft(tape); gap> TmTapeWrite(tape, TmSymbol('I')); gap> tape; <tape |__[I]I_|> gap> TmTapeRead(tape); <symbol 'I'>
‣ TmTape( ) | ( operation ) |
Returns: a turing tape
This operation creates an empty turing tape.
‣ TmTape( tape ) | ( operation ) |
Returns: a turing tape
This operation creates an turing tape with tape in its cells.
Each character in tape is converted to a Symbol. The character _ is special and is treated as the blank symbol.
‣ TmTapeRead( tape ) | ( operation ) |
Returns: the symbol the tapes head is pointing at.
This operations scans the cell the turing tape head is pointing at and returns the Symbol it has scanned.
gap> tape := TmTape(); <tape empty> gap> symbol := TmTapeRead(tape); <symbol blank>
‣ TmTapeWrite( tape, symbol ) | ( operation ) |
Returns: nothing
This operations writes symbol to the cell the turing tape head is pointing at.
gap> tape := TmTape();; gap> TmTapeWrite(tape, TmSymbol('I'));; gap> tape; <tape |__[I]__|>
‣ TmTapeHeadRight( tape ) | ( operation ) |
Returns: nothing
this operation moves the tape head right.
gap> tape := TmTape();; gap> TmTapeWrite(tape, TmSymbol('I'));; gap> TmTapeHeadRight(tape);; gap> tape; <tape |_I[_]__|>
‣ TmTapeHeadLeft( tape ) | ( operation ) |
Returns: nothing
this operation moves the tape head left.
gap> tape := TmTape();; gap> TmTapeWrite(tape, TmSymbol('I'));; gap> TmTapeHeadLeft(tape);; gap> tape; <tape |__[_]I_|>
‣ TmTapeHeadMove( tape, direction ) | ( operation ) |
Returns: nothing
this operation moves the tape head in Direction direction.
gap> tape := TmTape();; gap> TmTapeWrite(tape, TmSymbol('I'));; gap> TmTapeHeadRight(tape);; gap> tape; <tape |_I[_]__|>
generated by GAPDoc2HTML