Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
c0c30258
Commit
c0c30258
authored
May 15, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
turn spaces to tabs
replace ifs with switch still runs! SVN=118947
parent
9119f55e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
43 deletions
+43
-43
turing.go
test/turing.go
+43
-43
No files found.
test/turing.go
View file @
c0c30258
...
...
@@ -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
++
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment