Universal Turing machine: Difference between revisions

Content added Content deleted
Line 2,384: Line 2,384:
'>' : move right
'>' : move right
'@' : state <- op
'@' : state <- op
* : op <- *</pre>
<symbol> : op <- symbol</pre>


2. Interpreter
2. Interpreter
Line 2,395: Line 2,395:


<lang lisp>(defun run (table input state halt blank)
<lang lisp>(defun run (table input state halt blank)
;; bugs / questions : cyril nocton <cyril.nocton:gmail.com>
;; help : cyril nocton <cyril.nocton:gmail.com>
(let (lStack (rStack input) rule operand match)
(let (lStack (rStack input) code operand match)
(loop until (eql state halt) do
(loop until (eql state halt) do
(setf rule (cdr (assoc state table)) operand 'null match t)
(setf code (cdr (assoc state table)) operand 'null match t)
(dolist (symbol rule)
(dolist (symbol code)
(case symbol
(case symbol
(= (setf match (eql (car rStack) operand)))
(= (setf match (eql (car rStack) operand)))