A long time ago, in a country far far away, under the influence of Hoefstader's Godel, Escher, Bach, I spent a merry few minutes playing with programs that would print out themselves. One goal was to make a minimal such program in a particular language, another was to have a general scheme that could be added to make any program (in that language) do this (in addition to what the program was supposed to do). In pursuit of that latter goal I figured out some general ingredients that could be used to do this. These were:
- The ability to convert from an integer to a character.
- The ability to make decisions.
- The ability to iterate over a list.
With these, the scheme is as follows. Create a list containing the code converted into some integer representation of the symbols it contains. Insert into that list a special character (usually 0
is a safe bet) at a particular point. Then the program iterates through the list. Its normal behaviour is to convert each integer into the character it represents and output that. However, when it encounters 0
it simply outputs the list.
Here's a TeX version of that:
\tt
\parindent0pt
\emergencystretch3em
\def\A{92, 116, 116, 10, 92, 112, 97, 114, 105, 110, 100, 101, 110, 116, 48, 112, 116,
10, 92, 101, 109, 101, 114, 103, 101, 110, 99, 121, 115, 116, 114, 101, 116, 99, 104,
51, 101, 109, 10, 92, 100, 101, 102, 92, 65, 123, 0, 125, 10, 92, 108, 111, 110, 103, 92,
100, 101, 102, 92, 84, 35, 49, 44, 123, 37, 10, 92, 105, 102, 110, 117, 109, 35, 49, 60,
48, 92, 114, 101, 108, 97, 120, 10, 92, 101, 108, 115, 101, 10, 92, 105, 102, 110, 117,
109, 35, 49, 62, 48, 92, 114, 101, 108, 97, 120, 10, 92, 105, 102, 110, 117, 109, 35, 49,
61, 49, 48, 92, 114, 101, 108, 97, 120, 10, 92, 112, 97, 114, 10, 92, 101, 108, 115, 101,
10, 92, 99, 104, 97, 114, 35, 49, 10, 92, 102, 105, 10, 92, 101, 108, 115, 101, 10, 92,
65, 10, 92, 102, 105, 10, 92, 101, 120, 112, 97, 110, 100, 97, 102, 116, 101, 114, 92,
84, 92, 102, 105, 125, 10, 92, 101, 120, 112, 97, 110, 100, 97, 102, 116, 101, 114, 92,
84, 92, 65, 92, 98, 121, 101, -1, }
\long\def\T#1,{%
\ifnum#1<0\relax
\else
\ifnum#1>0\relax
\ifnum#1=10\relax
\par
\else
\char#1
\fi
\else
\A
\fi
\expandafter\T\fi}
\expandafter\T\A\bye
This produces:
Best Answer
The movie Stealth (2005) has the following storyline summary:
The artificial intelligence computer (or AI) was programmed by the character Dr Keith Orbit (played by Richard Roxburgh). Trivia for this movie includes a reference to LaTeX:
Here's a screen grab from the movie (1:09:06):