Skip to content

Commit af54744

Browse files
Merge branch 'release/0.0.1'
2 parents d78bc18 + 8fccfe9 commit af54744

File tree

18 files changed

+669
-0
lines changed

18 files changed

+669
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.a
2+
*.bak
3+
*.dSYM
4+
*.o
5+
*.sw*
6+
*.test
7+
*~
8+
/.bin

Godeps/Godeps.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Godeps/Readme

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Godeps/_workspace/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* The MIT License (MIT).
2+
*
3+
* https://github.com/jonathanmarvens/turing-machine
4+
*
5+
* Copyright (c) 2014 Jonathan Barronville (jonathan@belairlabs.com)
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10+
*
11+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
##########
2+
default: build
3+
##########
4+
5+
build: deps lint test
6+
gox -output=".bin/{{.OS}}-{{.Arch}}/turing-machine" -verbose
7+
8+
clean:
9+
rm -fr ./.bin
10+
11+
deps:
12+
godep go install -v -x ./...
13+
14+
errcheck:
15+
errcheck github.com/jonathanmarvens/turing-machine
16+
17+
fmt:
18+
gofmt -e -s -w .
19+
20+
lint: fmt errcheck
21+
22+
test: lint
23+
# TODO(@jonathanmarvens): Add some damn tests to fix this.
24+
25+
.PHONY: default
26+
.PHONY: build clean deps errcheck fmt lint test

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Turing machinez tho.
2+
3+
This is a simple turing machine I created for an article I’ve been writing titled, “*Neurons, turing machines, & lambda abstractions: an interesting combo?*
4+
5+
## Setup.
6+
7+
There are 3 ways you can install this on your system in order to play with it.
8+
9+
-----
10+
11+
__(1) Download a pre-built binary.__
12+
13+
You should be able to grab a pre-built binary on the [__Releases__ page](https://github.com/jonathanmarvens/turing-machine/releases) (oh, the power of Go cross-compiling __:)__ … I’m looking at you, GCC).
14+
15+
-----
16+
17+
Assuming you have your [Go workspace](http://golang.org/doc/code.html) all set up, the following are your two other options.
18+
19+
-----
20+
21+
__(2) Using `go get`.__
22+
23+
```sh
24+
go get -t -u github.com/jonathanmarvens/turing-machine
25+
```
26+
27+
-----
28+
29+
__(3) Building from source.__
30+
31+
```sh
32+
go get -t -u github.com/kisielk/errcheck github.com/mitchellh/gox github.com/tools/godep
33+
git clone https://github.com/jonathanmarvens/turing-machine.git $GOPATH/src/github.com/jonathanmarvens/turing-machine
34+
cd $GOPATH/src/github.com/jonathanmarvens/turing-machine
35+
make
36+
```
37+
38+
Now look in the __.bin/__ directory.
39+
40+
-----
41+
42+
## Usage.
43+
44+
Running `turing-machine help` should be helpful enough about the usage.
45+
46+
-----
47+
48+
Feel free to use the example *programs* in [__examples/__](https://github.com/jonathanmarvens/turing-machine/tree/master/examples).
49+
50+
```sh
51+
# ./.bin/{OS}-{ARCH}/turing-machine --prog="./examples/n-plus-1.btm.json"
52+
```
53+
54+
## Author.
55+
56+
__Jonathan Barronville__ < [__http://乔纳森.com__](http://乔纳森.com) > ( *jonathan@belairlabs.com* )
57+
58+
## Acknowledgements.
59+
60+
Here’s a great document that includes a formal (mathematical) definition of a turing machine (from Cornell University’s CS department): [http://www.cs.cornell.edu/courses/cs4820/2012su/handouts/turingm.pdf](http://www.cs.cornell.edu/courses/cs4820/2012su/handouts/turingm.pdf) … I liked this document more compared to like 6 others I read (the math is clearer and pretty straightforward to follow, there are real examples, the author doesn’t make stupid assumptions about things __-.-__, *et cetera*), so I (loosely) modeled the turing machine around it. You should read it if you want a better mathematical understanding of turing machines! Please don’t rely on Wikipedia for a good understanding of turing machines.
61+
62+
Here’s a good document, which also includes a formal definition of a turing machine: [http://plato.stanford.edu/entries/turing-machine](http://plato.stanford.edu/entries/turing-machine) … although I didn’t particularly love this document, it’s pretty informative (you probably wanna read it first if you’re new to turing machines).
63+
64+
## License.
65+
66+
See [__LICENSE__](https://github.com/jonathanmarvens/turing-machine/blob/master/LICENSE).

error/error.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* The MIT License (MIT).
3+
*
4+
* https://github.com/jonathanmarvens/turing-machine
5+
*
6+
* Copyright (c) 2014 Jonathan Barronville (jonathan@belairlabs.com)
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13+
*/
14+
15+
package error
16+
17+
import (
18+
"errors"
19+
)
20+
21+
func New(msg string) error {
22+
return errors.New("[github.com/jonathanmarvens/turing-machine]: " + msg)
23+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"K": [
3+
"l", "r0", "r1", "s"
4+
],
5+
6+
"s": "s",
7+
8+
"Σ": [
9+
"^", "$", "0", "1"
10+
],
11+
12+
"x": [
13+
"^", "0", "1", "0", "1", "1", "1", "0",
14+
"$"
15+
],
16+
17+
"δ": [
18+
{
19+
"map": {
20+
"dir": "R",
21+
"state": "r0",
22+
"sym": "^"
23+
},
24+
25+
"state": "s",
26+
"sym": "^"
27+
},
28+
29+
{
30+
"map": {
31+
"dir": "R",
32+
"state": "r0",
33+
"sym": "0"
34+
},
35+
36+
"state": "r0",
37+
"sym": "0"
38+
},
39+
40+
{
41+
"map": {
42+
"dir": "R",
43+
"state": "r1",
44+
"sym": "0"
45+
},
46+
47+
"state": "r0",
48+
"sym": "1"
49+
},
50+
51+
{
52+
"map": {
53+
"dir": "L",
54+
"state": "l",
55+
"sym": "0"
56+
},
57+
58+
"state": "r0",
59+
"sym": "$"
60+
},
61+
62+
{
63+
"map": {
64+
"dir": "R",
65+
"state": "r0",
66+
"sym": "1"
67+
},
68+
69+
"state": "r1",
70+
"sym": "0"
71+
},
72+
73+
{
74+
"map": {
75+
"dir": "R",
76+
"state": "r1",
77+
"sym": "1"
78+
},
79+
80+
"state": "r1",
81+
"sym": "1"
82+
},
83+
84+
{
85+
"map": {
86+
"dir": "L",
87+
"state": "l",
88+
"sym": "1"
89+
},
90+
91+
"state": "r1",
92+
"sym": "$"
93+
},
94+
95+
{
96+
"map": {
97+
"dir": "L",
98+
"state": "l",
99+
"sym": "0"
100+
},
101+
102+
"state": "l",
103+
"sym": "0"
104+
},
105+
106+
{
107+
"map": {
108+
"dir": "L",
109+
"state": "l",
110+
"sym": "1"
111+
},
112+
113+
"state": "l",
114+
"sym": "1"
115+
},
116+
117+
{
118+
"map": {
119+
"dir": "N",
120+
"state": "@HALT",
121+
"sym": "^"
122+
},
123+
124+
"state": "l",
125+
"sym": "^"
126+
}
127+
]
128+
}

0 commit comments

Comments
 (0)