~jacksonchen666/brainfuck_interpreter

8374e67a437165c0ad8a05a307311870c8211ba4 — Jackson Chen 1 year, 1 month ago cbc828b
fix nonsense
1 files changed, 5 insertions(+), 8 deletions(-)

M brainfuck.go
M brainfuck.go => brainfuck.go +5 -8
@@ 79,14 79,11 @@ func (ps *ProgramState) Step() error {
		ps.memoryPointer = newMemPointer
	case '>':
		ps.memoryPointer++
		if ps.memoryPointer >= len(*ps.tape) {
			// nuance behavior: limit max mem pointer to whatever size the
			// tape is.
			capacity := cap(*ps.tape)
			if ps.memoryPointer > capacity {
				ps.memoryPointer = capacity
			}
			*ps.tape = (*ps.tape)[:ps.memoryPointer]
		// nuance behavior: limit max mem pointer to whatever size the
		// tape is.
		capacity := cap(*ps.tape)
		if ps.memoryPointer+1 > capacity {
			ps.memoryPointer = capacity
		}
	case '.':
		char := string(currentMemory)