Skip to content

Commit

Permalink
duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jun 20, 2012
1 parent 0a0ccb1 commit c6aab50
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/dup/README.txt
@@ -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
36 changes: 36 additions & 0 deletions examples/dup/copy2.ctur
@@ -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

46 changes: 46 additions & 0 deletions examples/dup/copy2.t_l2
@@ -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

20 changes: 20 additions & 0 deletions examples/dup/dup.ctur
@@ -0,0 +1,20 @@
J020
J018
W0
MF
J14
MF
J16
W1
MF
W1
MB
J111
MB
J113
W1
MF
J12
MF
J118

25 changes: 25 additions & 0 deletions examples/dup/dup.t_l2
@@ -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

0 comments on commit c6aab50

Please sign in to comment.