-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a0ccb1
commit c6aab50
Showing
5 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
There are two simple Turing Machine programs that duplicate a unary number. | ||
|
||
copy2 is the naïve implementation of concatenating two copy (cf.) programs. | ||
It requires the first bit set to 0 in order to find it back. | ||
(In the Rascal emulator you cannot move backwards farther than your starting position) | ||
|
||
e.g.: 0110… ⇒ 011011110… | ||
|
||
dup is a slightly less naïve but stupid implementation, which does what copy (cf.) does, | ||
but adds two bits on each iteration. | ||
It shows how Turing Machine programming does not have to be rocket science. | ||
|
||
-- Vadim Zaytsev, http://grammarware.net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
MF | ||
J036 | ||
J034 | ||
W0 | ||
MF | ||
J15 | ||
MF | ||
J17 | ||
W1 | ||
MB | ||
J110 | ||
MB | ||
J112 | ||
W1 | ||
MF | ||
J13 | ||
MB | ||
J117 | ||
MF | ||
J034 | ||
W0 | ||
MF | ||
J122 | ||
MF | ||
J124 | ||
W1 | ||
MB | ||
J127 | ||
MB | ||
J129 | ||
W1 | ||
MF | ||
J120 | ||
MF | ||
J134 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
MF | ||
J0 stop | ||
L loop | ||
J0 exit | ||
W0 | ||
REP 2 { | ||
L skip | ||
MF | ||
J1 skip | ||
} | ||
W1 | ||
REP 2 { | ||
L back | ||
MB | ||
J1 back | ||
} | ||
W1 | ||
MF | ||
J1 loop | ||
L back2 | ||
MB | ||
J1 back2 | ||
MF | ||
L loop2 | ||
J0 exit | ||
W0 | ||
REP 2 { | ||
L skip2 | ||
MF | ||
J1 skip2 | ||
} | ||
W1 | ||
REP 2 { | ||
L back3 | ||
MB | ||
J1 back3 | ||
} | ||
W1 | ||
MF | ||
J1 loop2 | ||
L exit | ||
L end | ||
MF | ||
J1 end | ||
L stop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
J020 | ||
J018 | ||
W0 | ||
MF | ||
J14 | ||
MF | ||
J16 | ||
W1 | ||
MF | ||
W1 | ||
MB | ||
J111 | ||
MB | ||
J113 | ||
W1 | ||
MF | ||
J12 | ||
MF | ||
J118 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
J0 stop | ||
L loop | ||
J0 end | ||
W0 | ||
REP 2 { | ||
L skip | ||
MF | ||
J1 skip | ||
} | ||
W1 | ||
MF | ||
W1 | ||
REP 2 { | ||
L back | ||
MB | ||
J1 back | ||
} | ||
W1 | ||
MF | ||
J1 loop | ||
L end | ||
MF | ||
J1 end | ||
L stop | ||
|