summaryrefslogtreecommitdiff
path: root/test/turing.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2008-05-15 15:20:59 -0700
committerRob Pike <r@golang.org>2008-05-15 15:20:59 -0700
commitfd4ade3c1bc3bb0a3ec4ed20d76ce169bc32754a (patch)
tree6a38b2ef49aeb51a4194051a2d346f8b7b53e25e /test/turing.go
parent4a597fb85581e8048640535cd1ead65ddede7216 (diff)
downloadgo-fd4ade3c1bc3bb0a3ec4ed20d76ce169bc32754a.tar.gz
turn spaces to tabs
replace ifs with switch still runs! SVN=118947
Diffstat (limited to 'test/turing.go')
-rw-r--r--test/turing.go86
1 files changed, 43 insertions, 43 deletions
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++;
+ }
}