Welcome to the Pit!

[Blue Ribbon]

INTERCAL is a programming language like no other. This is good, or at least, it is good that other languages are as unlike INTERCAL as possible. This page is a showcase, or freak show, of INTERCAL source code. A distribution including the reference manual by Woods and Lyon, and Eric Raymond's C-INTERCAL compiler, is available from The Retrocomputing Museum. Text files of the original manual and the supplemental manual describing additional features of the C-INTERCAL compiler are available at

while Brian Raiter has put up an HTML version of the combined manual and a new INTERCAL Resources page.

Little code has ever been written in INTERCAL, most wimps being content to just read the manual, so it will be interesting to see what new and horrible things can yet be accomplished with the language. There are some sources on this page not available with the standard distribution, and more are welcome. You could send them to me, but it might be better to post to alt.lang.intercal and try to get some traffic going there again.

Other sites with INTERCAL source

INTERCAL Resource Page
Eric Raymond's INTERCAL page, with links to the latest versions of the manual and the distribution.
Baby's First INTERCAL Program
Program by Darren Stuart Embry counts down from 500. Works except for an easily-corrected syntax error.
99 Bottles of Beer on the Wall
This page has programs, in 111 different programming languages, for printing out the song. The INTERCAL version is by Matt Dimeo.
Jacob Mandelson's INTERCAL Page
New page (as I write this), with links to a couple of INTERCAL programs.

A new exponentiation routine

This routine raises .1 to the .2 power, returning the result in :1. When called through (2040) it dies with an error message on overflow. When called through (2049) it returns #2 in .4 on overflow, otherwise .4 is set to #1.

This was one of the programming suggestions from the original manual. Of the others, the sorting routine, the prime number table, and a program to compute pi have been done. The remaining suggestions are to write a floating point library and an FFT.

[If you see garbage below, either your browser cannot handle the table or I've botched something up. You can get this exponentiation routine as part of the powers program, and there is a link to a more efficient version farther down.]

(2040)  PLEASE STASH .4
        DO ABSTAIN FROM (2047)
(2049)  DO STASH .1 + .2 + :2 + :3 + :4 + :5 + :6
        PLEASE DO .4 <- #1
        DO :5 <- .1
        DO :6 <- #1
Initialization for both entry points.
        DO (2044) NEXT
We will return to this point when the computation is finished.
(2047)  DO (2048) NEXT
        DO .1 <- .4
        DO (2046) NEXT
        DO (1999) NEXT
(2046)  DO (2042) NEXT
        PLEASE REINSTATE (2047)
This section causes an error on overflow, if enabled. (1999) is an error statement in the standard library.
(2048)  DO :1 <- :6
        DO RETRIEVE .1 + .2 + :2 + :3 + :4 + :5 + :6
        PLEASE RESUME #2
Clean up and return.
(2044)  DO (2045) NEXT
(2045)  PLEASE FORGET #1
Top of main loop.
        DO .1 <- "?!2~#1'$#1"~#3
        DO (2041) NEXT
        PLEASE DO :1 <- :6
        PLEASE DO :2 <- :5
        DO (1549) NEXT
        DO :6 <- :3
        DO .4 <- '?"'V.4$":4~#3"'~#4"$#1'~#3
        DO (2043) NEXT
(2042)  PLEASE RESUME .1
(2041)  DO (2042) NEXT
(2043)  PLEASE FORGET #1
At this point, :5 contains .1 raised to the power of a power of 2. If the corresponding bit in .2 is set, we use the (1549)multiplication routine in the standard library to multiply in into the result accumulator :6.
        DO .2 <- .2~#65534
Shift .2 to the right to bring the next bit into position.
        DO .1 <- '?"!2~.2'~#1"$#2'~#3
        DO (2042) NEXT
        PLEASE DO :1 <- :5
        PLEASE DO :2 <- :5
        DO (1549) NEXT
        DO :5 <- :3
        DO .4 <- '?"'V.4$":4~#3"'~#4"$#1'~#3
If .2 is now #0, return to clean up section, otherwise square the quantity in :5 and go through the main loop again.
        DO (2045) NEXT
Bottom of main loop.

COME FROM statements have been avoided so that this could be a library routine called from "standard" INTERCAL programs.

The expressions '?"'V.4$":4~#3"'~#4"$#1'~#3 preserve the overflow flags. .4 and :4 are either #1 or #2, and these expressions return #2 if either of the inputs are #2.

The version in the supplemental library has some enhancements over this one. The overflow accumulation is simplified, setting .4 to #1 on overflow or #0 otherwise during the loop and then converting it to #2 or #1 when ready to return. Also, one or more multiplications are eliminated by checking that :6 is at least #2 before multiplying it by :5. I have not investigated whether it might be more efficient to return or terminate immediately after the first overflow, instead of working through the entire exponent.

Files available at this site

from original manual:
Sample program
Returns absolute value of a 16-bit 2's-complement number. A bug in the version in the manual has been fixed: one of the mingles was backwards.
Standard library
Implements basic arithmetic operations not included in the INTERCAL language: addition, subtraction, multiplication, division; as well as two routines returning random deviates. [comments]
Original standard library
This is the original version from the manual, which has a couple of bugs in the 32-bit routines.
by Jon Blow, blojo@ocf.berkeley.edu:
Simple program to test the "Black Lagoon" compiler feature. [comments]
Random number program. [comments]
Increment .1 (for those of you not yet fluent in INTERCAL, note that .1 is a variable).
by Hans Olsson, f88ho@efd.lth.se:
1910 routine
A re-implementation of the 1910 normal random deviate routine.
by Louis Howell, nazgul@netcom.com:
Conway's game of Life, standard INTERCAL version. [comments]
Life 2
This version uses COME FROM and character output. [comments]
blinkers, t-tetromino, glider, glider gun
Input files for both Life programs.
Bubble sort
An attempt at a reusable code module, in INTERCAL! [comments]
Sends inputs to output. This is almost too easy, reflecting badly on the I/O extensions in the compiler.
Supplemental library
New library routines: decrement, decrement and branch on 0, add bit, 16-bit division with remainder, exponentiation (latest version). [comments]
Prints digits of pi. [comments]
Prints a list of prime numbers. [comments]
Test program for exponentiation routine (original version), prints a list of nth powers.
[NEW] I Ching 1
Generates hexagrams using a simulated ``coin oracle'' method.
[NEW] I Ching 2
Expanded version includes a lookup table to find the positions of the hexagrams in the traditional sequence. [comments]
by Jacob Mandelson, jlm@cco.caltech.edu:
Prints ROT-13 of its input. [comments]
by Jan-Pieter Cornet, johnpc@xs4all.nl:
Hail Mary
Prints 1,000,000 Hail-Mary's. Written in TriINTERCAL, currently this and the next file are the only nontrivial programs in this dialect known to exist. [comments]
Count to 10
Counts to 10 in TriINTERCAL. [comments]
I/O gerunds
Demonstrate gerund abstention. [comments]
by Clemens Meier, clmeier@lili.uni-bielefeld.de:
Another ROT-13 program. [comments]
by Matt DiMeo, mdimeo@brooktree.com:
99 Bottles of Beer on the Wall
Prints out the entire song. [comments]
by Brian Raiter, breadbox@muppetlabs.com:
Numerical I/O library
Routines for wimp-mode I/O. [comments]
[NEW] More standard libraries
This tarfile contains the standard library re-written for each of the bases 3 through 7.
[NEW] Hello, World
``Hello, World'' program
tarfile of sources available on this page (and some others not listed individually):
pit.tar.gz, 40221 bytes
Includes all INTERCAL programs distributed with the 0.15 release, and more.

[Hit Counter]

On August 9, 1996 this page was selected Geek Site of the Day.

Maintainer: Louis Howell