diff options
author | Rob Pike <r@golang.org> | 2008-05-15 15:20:59 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2008-05-15 15:20:59 -0700 |
commit | c0c30258be6f596bb081a6cc0ae89a2502f77e4d (patch) | |
tree | 6a38b2ef49aeb51a4194051a2d346f8b7b53e25e /test/turing.go | |
parent | 9119f55e6dac9fd33bb94c4c00b7d5531286a56d (diff) | |
download | go-c0c30258be6f596bb081a6cc0ae89a2502f77e4d.tar.gz go-c0c30258be6f596bb081a6cc0ae89a2502f77e4d.zip |
turn spaces to tabs
replace ifs with switch
still runs!
SVN=118947
Diffstat (limited to 'test/turing.go')
-rw-r--r-- | test/turing.go | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/test/turing.go b/test/turing.go index a7a8ea7863..2b6b69b18a 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++; + } } |