Skip to: Site menu | Main content

"Young man," said von Neumann, "in mathematics you don't understand things, you just get used to them."

--quoted in G. Zukav The Dancing Wu Li Masters.

A Turing machine in TeX

This is an small example of the use of TeX as a programming language. You can use these kind of programming techniques to make your documents look nicer.

To try it:

  • Download it. There three examples included, which can be run with tex example, tex example2, tex example3.
  • See the README file (included in the package).

Here is an example of input document (file example.tex in the package):

\input turing.tex

\Tape{00000>1111000}
\Stat{q0}

\Program{ {q0,1,R,q1}
          {q1,1,R,q0}
          {q1,0,R,q2}
          {q2,0,1,q3} }

\run

This program decides whether the number of 1's in the tape is even or odd. The output of tex example is

small example

(click to see the full pdf output: 3 pages).

 

Updated on: 02:10 PM, Thursday Nov 26, 2009