Universal Turing machine: Difference between revisions

no edit summary
(→‎Program: Improve style.)
No edit summary
Line 2,382:
'@' : state <- arg
<symbol> : arg <- symbol</pre>
 
====Program====
 
Tape is split into two stacks.
 
<pre>T = reverse (l) . r where r is the scanned symbol.
0</pre>
 
<syntaxhighlight lang="lisp">;;; 23.01.16
 
(defun acl (table input state halt blank)
(loop for code = (cdr (assoc state table))
with l = nil
with r = input
with op = nil
with x = t
until (eql state halt)
do (dolist (c code)
(case c
(= (setf x (eql (car r) op)))
(% (when x (rplaca r op)))
(< (when x (push (pop l) r)))
(> (when x (push (pop r) l)))
(@ (when x (setf state op) (return)))
(t (setf op c)))
(unless (car r)
(setf r (cons blank (cdr r)))))
finally (format t "Q = (~a ~{~a~}.~{~a~})~%" state (reverse l) r)))</syntaxhighlight>
 
====Tables====
422

edits