From fd4ade3c1bc3bb0a3ec4ed20d76ce169bc32754a Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Thu, 15 May 2008 15:20:59 -0700 Subject: turn spaces to tabs replace ifs with switch still runs! SVN=118947 --- test/turing.go | 86 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'test/turing.go') diff --git a/test/turing.go b/test/turing.go index a7a8ea786..2b6b69b18 100644 --- a/test/turing.go +++ b/test/turing.go @@ -9,47 +9,47 @@ package main // brainfuck func main() { - var a [30000]byte; - prog := "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>."; - p := 0; - pc := 0; - for { - switch prog[pc] { - case '>': - p++; - case '<': - p--; - case '+': - a[p]++; - case '-': - a[p]--; - case '.': - print string(a[p]); - case '[': - if a[p] == 0 { - for nest := 1; nest > 0; pc++ { - if prog[pc+1] == ']' { - nest--; - } - if prog[pc+1] == '[' { - nest++; - } - } - } - case ']': - if a[p] != 0 { - for nest := -1; nest < 0; pc-- { - if prog[pc-1] == ']' { - nest--; - } - if prog[pc-1] == '[' { - nest++; - } - } - } - default: - return; - } - pc++; - } + var a [30000]byte; + prog := "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>."; + p := 0; + pc := 0; + for { + switch prog[pc] { + case '>': + p++; + case '<': + p--; + case '+': + a[p]++; + case '-': + a[p]--; + case '.': + print string(a[p]); + case '[': + if a[p] == 0 { + for nest := 1; nest > 0; pc++ { + switch prog[pc+1] { + case ']': + nest--; + case '[': + nest++; + } + } + } + case ']': + if a[p] != 0 { + for nest := -1; nest < 0; pc-- { + switch prog[pc-1] { + case ']': + nest--; + case '[': + nest++; + } + } + } + default: + return; + } + pc++; + } } -- cgit v1.2.1