TPK Algorithm in Different Programming Languages

The TPK algorithm reads in an array of 11 values, applies a particular function to each value, and then writes the result in reverse order. It serves just to illustrate some of the usual actions that an imperative programming language must perform. It was used in

Knuth, Donald Ervin, and Luis Trabb Pardo. ``The early development of programming languages.'' In Encyclopedia of Computer Science and Technology, Marcel Dekker, New York, 1977, pages 419-96.
to compare many early programming languages. We use the same algorithm to compare some more recent programming languages.
  1. TPK program in Ada
  2. TPK program in C
  3. TPK program in C++
  4. TPK program in C#
  5. TPK program in FORTRAN 95
  6. TPK program in Haskell
  7. TPK program in Java
  8. TPK program in Modula-3
  9. TPK program in BASIC
  10. TPK program in QBASIC
  11. TPK program in ICON
  1. TPK program in SML
  2. TPK program in Common Lisp

One WWW page, 99 Bottles of Beer, has a collection of over 1000 programs in different languages that print out the same ditty. Nearly as many versions of "Hello, World!" program can be found at the "Hello, World!" WWW page.

Ryan Stansifer <>
Last modified: Tue Jul 12 22:36:26 EDT 2011