Kvikkalkul: An Example Program

After posting the first two messages describing Kvikkalkul, the anonymous programmer received numerous requests for an example of source code in the language. Although the message headers are lost to antiquity, at some point he posted the following example, probably to the newsgroup alt.folklore.computers.

This third message follows:

1000000 Hail Mary's in kvikkalkul.

I got many requests for a real program in kvikkalkul. Here is one, without comments of course.

666/ 5
/0 -) 666
:1 -) 550
:0 -) 1010
-) :1
1010:
:1 -) 888
:0 -) 1020
-) :1
1020:
/0 -) 666
:1 -) 1030
:2 -) 1040
:0 -) 1050
:3 -) 560
.9 (- ,0
1030:
.8 (- ,0
1040:
-) :3
1050:
.8 (- .8 -/- ,0005
.8 ( ,49975 -) :2
.9 (- .9 -/- ,0005
.9 ( ,49975 -) :1
:1 -) 666
-) :1

Notes:

  1. This progrram uses the library routines 550 and 560 for reading and writing a line on the teletype in packed 3 per number format. The line is stored in data area 666, which holds 5 numbers, 15 chars.
  2. The first time you run the program it reads a line from the teletype and you have to type the line "hail mary". Then it dumps the memory contents to paper tape (888). The compiler constructs a production binary from that memory dump and the original program binary. This binary will start at label 1020:
  3. This is really sloppy code. It uses fractional numbers such as 0.0005 that are not exactly represented in binary. Serious programs used exact powers of 2 for counters, like 1/1024 ( ,0009765625)
  4. No way we would ever attempt to run such silliness! It would eat several boxes of paper and the computer time would cost a large multiple of the paper.
  5. Kvikkalkul isn't that bad for expressing algorithms, once you get used to it.

Return to Main Page