Beispiel #1
0
 inline void print_tape() {
     if (tape_changed) {
         for (int i=0; i<tape.size(); i++)
             cout << tape[i];
         cout << endl;
     }
 }
Beispiel #2
0
    inline void move_head(char move) {
        if (move == 'l')
            pos -= 1;
        else if (move == 'r')
            pos += 1;
        else
            throw string("unknown state");

        if (pos < 0) {
            tape.insert(tape.begin(), init);
            pos = 0;
        }
        if (pos >= tape.size()) {
            tape.push_back(init);
        }
        moves++;
    }