The TPK (Knuth & Pardo) program was concocted by DonaldKnuth and Luis Trabb Pardo as part of their work "The early development of Programming Languages" which appeared in A History of Computing in the Twentieth Century (ISBN 0-12-491650-3 Metropolis, N., Howlett, J., Cota, Gian-Carlo, eds., Academic Press, New York, 1980). Their idea was to introduce a trivial program which involved arrays, indexing, transcendental functions, subroutines, input, output, conditionals, and iteration, and then to demonstrate how several early (pre-1960) languages implemented such concepts. Examples of TPK are somehow much more satisfying than HelloWorlds.

The example given, which is claimed to be the original, doesn't actually have any transcendental functions.

Sub main()
Dim a(0 To 10) As Double, i As Long, y As Double
For i = 0 To 10
a(i) = InputBox("")
Next i
For i = 10 To 0 Step -1
y = f(a(i))
If y > 400 Then
MsgBox "Too Big", vbExclamation, CStr(i)
Else
MsgBox CStr(y), , CStr(i)
End If
Next i
End Sub

It would be interesting to see a solution in an array-oriented language like APL, J, K, L, etc.
As usual, I come up with a good idea and then find someone else has already carried it out. Check out http://cs.fit.edu/~ryan/compare/ for more of this sort of thing (note, connection is slow). -- DavidBrantley
See also: