Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
43 deletions
+43
-43
test/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