Universal Turing machine: Difference between revisions

m
Line 2,372:
5-state busy beaver (first 20 cells)
10100100100100100100...</pre>
===Control languageAcl===
Tmcl is a tiny Turing machine control language.
 
TmclAcl is a tiny Turing a-machine control language. Instructions are
====Instruction set====
 
<pre>'=' : if scanned symbol = oparg do
Tmcl uses postfix notation.
'%' : print oparg
 
<pre>'=' : if scanned symbol = op do
'%' : print op
'<' : move left
'>' : move right
'@' : state <- oparg
<symbol> : oparg <- symbol</pre>
 
====Program====
Line 2,390 ⟶ 2,387:
Tape is split into two stacks.
 
<pre>T = reverse (leftl) . rightr where rightr is the scanned symbol.
0</pre>
 
<syntaxhighlight lang="lisp">;; 22.1112.23 (Mise en forme du code)
 
(defun runacl (programtable input state halt blank)
(let ((leftl nil)
(rightr input)
(operandarg nil)
(matchexe nil))
(loop :until (equal state halt)
:do (setf routinecode (restcdr (assoc state program)table))
(setf match exe t)
(dolist (tokenc routinecode)
(case tokenc
(= (setf matchexe (equal (firstcar rightr) operandarg)))
(% (when matchexe (rplaca rightr operandarg)))
(< (when matchexe (push (pop leftl) rightr)))
(> (when matchexe (push (pop rightr) leftl)))
(@ (when matchexe (setf state operandarg) (return)))
(t (setf operandarg tokenc)))
(unless (firstcar rightr)
(setf rightr (cons blank (restcdr rightr))))))
(format t "Q = <~a, ~{~a~}.~{~a~}>~%" state (reverse leftl) rightr)))</syntaxhighlight>
 
====CodeTables====
 
codeTables isare stored in association lists.
 
<syntaxhighlight lang="lisp">(defconstant +incrementer+ '((q0 . (1 = > q0 @ b = 1 % qf @))))
Line 2,426 ⟶ 2,423:
 
====Execution====
 
<pre>(runacl +incrementer+ '(1 1 1) 'q0 '(qf) 'b)
(runacl +three-states-buzy-beaver+ '(0) 'a '(halt) '0)</pre>
 
{{out}}
<pre>
<pre>(run +incrementer+ '(1 1 1) 'q0 '(qf) 'b)
Q = <QF, 111.1>
(run +three-states-buzy-beaver+ '(0) 'a '(halt) '0)
Q = <HALT, 111.111></pre>
 
422

edits