Goto Chapter: Top 1 2 3 4 5 6 7 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

3 Tape
 3.1 Constructor
 3.2 Reading and Writing
 3.3 Moving

3 Tape

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

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'>

3.1 Constructor

3.1-1 TmTape
‣ TmTape( )( operation )

Returns: a turing tape

This operation creates an empty turing tape.

3.1-2 TmTape
‣ 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.

3.2 Reading and Writing

3.2-1 TmTapeRead
‣ 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>

3.2-2 TmTapeWrite
‣ 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]__|>

3.3 Moving

3.3-1 TmTapeHeadRight
‣ 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[_]__|>

3.3-2 TmTapeHeadLeft
‣ 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_|>

3.3-3 TmTapeHeadMove
‣ 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[_]__|>
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 Ind

generated by GAPDoc2HTML