# X-NEWS: spcvxb alt.lang.intercal: 4 M Relay-Version: VMS News - V5.9C-01 30/04/90 VAX/VMS V5.3; site spcvxb.spc.edu + Path: spcvxb!njin!rutgers!cbmvax!snark!eric  Newsgroups: alt.lang.intercal F Subject: Heeere she is, Miss Amerrr....No! No! AAAGH! it's C-INTERCAL!? Message-ID: <1WPqh8#5Oh1SB3CPSfC04BdgW9ZP25p=eric@snark.uu.net> ) From: eric@snark.uu.net (Eric S. Raymond)  Date: 12 May 90 16:29:49 GMT Lines: 2638   E Yes, masochist hackers of the world, it's that horrible moment you've . all been waiting for...THE RETURN OF INTERCAL!  	 #!/bin/sh C : "This is a shell archive, meaning:                              " C : "1. Remove everything above the #! /bin/sh line.                " C : "2. Save the resulting test in a file.                          " C : "3. Execute the file with /bin/sh (not csh) to create the files:"  : "	READ.ME" : "	intercal.man"  : "	intercal.tex"  : "	intercal.sty" 	 : "	BUGS"  : "	THEORY" 
 : "	Makefile"  : "	cesspool.c"  : "	cesspool.h" 
 : "	feh.c"
 : "	fiddle.c" 
 : "	ick.h"
 : "	ick.y" : "	lose.c"  : "	lose.h"  : "	lexer.l" : "	ick-wrapper.c"
 : "	sample.i" 7 : "This archive created:  "Sat May 12 12:24:39 EDT 1990  echo file: READ.ME) sed 's/^X//' >READ.ME << 'END-of-READ.ME'  X			C-INTERCAL (v 0.3) X ; X	NOTE! THIS IS A PRE-RELEASE VERSION WITH SOME KNOWN BUGS! A X	SEE THE `BUGS' FILE FOR DETAILS, AND EARN THE ETERNAL GRATITUDE : X	OF THE HUGE, BUSTLING INTERCAL COMMUNITY BY FIXING THEM! X K XThis package is an implementation of the language INTERCAL designed by Don J XWoods and James Lyon, who have since spent most of twenty years trying to Xlive it down. X I XThe implementation was created by Eric S. Raymond (...!uunet!snark!eric) K Xduring a fit of lunacy from which he has since mostly recovered. The files  Xincluded are: X  XREAD.ME		-- this file6 Xintercal.man	-- The INTERCAL manual (read this next!)  Xintercal.tex	-- TeX source form Xintercal.sty	-- TeX style file @ XTHEORY		-- some notes on the internals of the INTERCAL compiler* XBUGS		-- notes pertaining to this release X / XMakefile	-- makefile for the INTERCAL compiler 8 Xlexer.l		-- the lexical analyzer specification (in LEX). Xick.y		-- the grammar specification (in YACC)( Xick.h		-- compilation types and defines' Xfeh.c		-- INTERCAL-to-C code generator # Xfiddle.c	-- the INTERCAL operators ; Xlose.[ch]	-- INTERCAL compile- and run-time error handling ? Xick-wrapper.c	-- the driver for generated C-from-INTERCAL code 0 Xcesspool.c	-- the INTERCAL runtime support codeK Xcesspool.h	-- interface fr. generated code to the INTERCAL runtime support  X 8 Xsample.i	-- a sample INTERCAL program (from the manual) X E XYou want a man page? Man pages are for wimps. To compile an INTERCAL , Xprogram `foo.i' to executable code, just do X  X	ick foo.i  X C XThere's a -d option that leaves the generated `foo.c' in place for G Xinspection (suppressing compilation to machine code), and an -O option D Xthat enables the (hah!) optimizer. Other than that, yer on yer own. X A XOne other switch affects C-intercal's runtime behavior. The `-C' F Xoption forces output in "clockface" mode, for superstitious users whoB Xbelieve writing "IV" upside-down offends IVPITER and would rather
 Xsee IIII. X D XReport bugs, if you absolutely must, to the author. Or post them to! Xalt.lang.intercal. Or something.  END-of-READ.ME echo file: intercal.man 3 sed 's/^X//' >intercal.man << 'END-of-intercal.man'  X  X  X  X  X  X % X			THE INTERCAL PROGRAMMING LANGUAGE  X				REFERENCE MANUAL  X  X # X			Donald R. Woods & James M. Lyon  X 2 X		Copyright Donald R. Woods & James M. Lyon  1973 X  X X  X  X  X  X 
 X				INTERCAL  X  X1. INTRODUCTION X P XThe names you are about to ignore are true. However, the story has been changedJ Xsignificantly. Any resemblance of the programming language portrayed hereH Xto other programming languages, living or dead, is purely coincidental. X  X1.1 ORIGIN AND PURPOSE  X K XThe INTERCAL programming language was designed the morning of May 26, 1972 L Xby Donald R. Woods and James M. Lyon, at Princeton University. Exactly whenJ Xin the morning will become apparent in the course of this manual. It was L Xinspired by one ambition; to have a compiler language which has nothing at K Xall in common with any other major language. By 'major' was meant anything J Xwith which the authors were at all familiar, e.g., FORTRAN, BASIC, COBOL,J XALGOL, SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP, and PI/I. For theK Xmost part, INTERCAL has remained true to this goal, sharing only the basic N Xelements such as variables, arrays, and the ability to do I/O, and eschewing I Xall conventional operations other than the assignment statement (FORTRAN  X"="). X  X1.2 ACRONYM X J XThe full name of the compiler is "Compiler Language With No PronounceableA XAcronym", which is, for obvious reasons, abbreviated "INTERCAL".  X  X1.3 ACKNOWLEDGMENTS X J XThe authors are deeply indebted to Eric M. Van and Daniel J. Warmenhoven,E Xwithout whose unwitting assistance this manual would still have been 
 Xpossible. X  X  X X  X  X  X  X  X2. FUNDAMENTAL CONCEPTS X K XIn this section an attempt is made to describe how and why INTERCAL may be 5 Xused; i.e., what it is like and what it is good for.  X  X2.1 SAMPLE PROGRAM  X N XShown below is a relatively simple INTERCAL program which will read in 32-bitP Xunsigned integers, treat them as signed, 2's-complement numbers, and print out M Xtheir absolute values. The program exits if the absolute value is zero. Note K Xin particular the inversion routine (statements 6 through 14), which could K Xbe greatly simplified if the subroutine library (see section 5) were used.  X K XA more detailed analysis of a program is made in section 6 of this manual.  X 
 X	DO (5) NEXT  X    (5) DO FORGET #1  X	PLEASE WRITE IN :1$ X	DO .1 <- 'V":1~'#32768$#0'"$#1'~#3
 X	DO (1) NEXT & X	DO :1 <- "'V":1~'#65535$#0'"$#65535'$ X		~'#0$#65535'"$"'V":1~'#0$#65535'" X		$#65535'~'#0$#65535'"
 X	DO :2 <- #1  X	PLEASE DO (4) NEXT X    (4) DO FORGET #1 * X	DO .1 <- "'V":1~'#65535$#0'"$":2~'#65535! X		$#0'"'~'#0$#65535'"$"'V":1~'#0 + X		$#65535'"$":2~'#65535$#0'"'~'#0$#65535'" 
 X	DO (1) NEXT  X	DO :2 <- ":2~'#0$#65535'" ' X		$"'":2~'#65535$#0'"$#0'~'#32767$#1'" 
 X	DO (4) NEXT  X    (2) DO RESUME .1  X    (1) PLEASE DO (2) NEXT  X	PLEASE FORGET #1 X	DO READ OUT :1' X	PLEASE DO .1 <- 'V"':1~:1'~#1"$#1'~#3 
 X	DO (3) NEXT  X	PLEASE DO (5) NEXT X    (3) DO (2) NEXT X	PLEASE GIVE UP X  X2.2 USES FOR INTERCAL X I XINTERCAL's main advantage over other programming languages is its strict L Xsimplicity. It has few capabilities, and thus there are few restrictions toH Xbe kept in mind. Since it is an exceedingly easy language to learn, oneL Xmight expect it would be a good language for initiating novice programmers.F XPerhaps surprising, than, is the fact that it would be more likely toK Xinitiate a novice into a search for another line of work. As it turns out, D XINTERCAL is more useful (which isn't saying much) as a challenge toL Xprofessional programmers.  Those who doubt this need only refer back to theH Xsample program in section 2.1. This 23-statement program took somewhereL Xfrom 15 to 30 minutes to write, whereas the same objectives can be achieved/ Xby single-statement programs in either SNOBOL;  X   X	PLEASE INPUT POS(0) ('-' ! '')! X	+ (SPAN('0123456789') $ OUTPUT)   X	+ *NE(OUTPUT) :S(PLEASE)F(END) X  Xor APL; X  X	[1] >-0=/?<-? X F XAdmittedly, neither of these is likely to appear more intelligible toH Xanyone unfamiliar with the languages involved, but they took roughly 60I Xseconds and 15 seconds, respectively, to write. Such is the overwhelming  Xpower of INTERCAL!  X K XThe other major importance of INTERCAL lies in its seemingly inexhaustible L Xcapacity for amazing one's fellow programmers, confounding programming shopJ Xmanagers, winning friends, and influencing people. It is a well-known andK Xoft-demonstrated fact that a person whose work is incomprehensible is held K Xin high esteem. For example, if one were to state that the simplest way to 9 Xstore a value of 65535 in a 32-bit INTERCAL variable is:e Xo X	DO :1 <- #0?#256 X3F Xany sensible programmer would say that that was absurd. Since this isL Xindeed the simplest method, the programmer would be made to look foolish inJ Xfront of his boss, who would of course happened to turn up, as bosses areG Xwont to do. The effect would be no less devastating for the programmerd Xhaving been correct.2 X9 X Xi X: X3 X  Xe X3. DESCRIPTIONe XoJ XThe examples of INTERCAL programming which have appeared in the precedingK Xsections of this manual have probably seemed highly esoteric to the reader F Xunfamiliar with the language. With the aim of making them more so, we( Xpresent here a description of INTERCAL. Xi Xt X3.1 VARIABLES X H XINTERCAL allows only 2 different types of variables, the 16-bit integerH Xand the 32-bit integer. These are represented by a spot (.) or two-spotJ X(:), respectively, followed by any number between 1 and 65535, inclusive.J XThese variables may contain only non-negative numbers; thus they have theL Xrespective ranges of values: 0 to 65535 and 0 to 4294967295. Note: .123 andE X:123 are two distinct variables. On the other hand, .1 and .0001 are.@ Xidentical.  Furthermore, the latter may NOT be written as 1E-3. X) X3.2 CONSTANTS XII XConstants are 16-bit values only and may range from 0 to 65535. They areEI Xprefixed by a mesh (#). Caution! Under no circumstances confuse the meshMD Xwith the interleave operator, except under confusing circumstances! Xg X3.3 ARRAYS  XiL XArrays are represented by a tail (,) for 16-bit values, or a hybrid (;) forH X32-bit values, followed by a number between 1 and 65535, inclusive. TheJ Xnumber is suffixed by the word SUB, followed by the subscripts, separatedI Xoptionally by spaces. Subscripts may be any expressions, including thoseiF Xinvolving subscripted variables. This occasionally leads to ambiguousM Xconstructions, which are resolved as discussed in section 3.4.3.  DefinitionoE Xof array dimensions will be discussed later in greater detail, since J Xdiscussing it in less detail would be difficult. As before, ,123 and ;123D Xare distinct.  In summary, .123, :123, #123, ,123, and :123 are all
 Xdistinct. Xn X3.4 OPERATORS X	J XINTERCAL recognizes 5 operators--2 binary and 3 unary. Please be kind to L Xour operators: they may not be very intelligent, but they're all we've got.J XIn a sense, all 5 operators are binary, as they are all bit-oriented, but< Xit is not our purpose here to quibble about bits of trivia. Xs Xo XH X******* proofread versus the paper copy only this far !!!! ************ X. X- Xs Xl X3.4.1 BINARY OPERATORSt XmK XThe binary operators are INTERLEAVE (also called MINGLE) and SELECT, whichRI Xare represented by a change (c/) and a sqiggle [sic] (~), respectively.T XeM XThe interleave operator takes two 16-bit values and produces a 32-bit resultpJ Xby alternating the bits of the operands. Thus, #65535c/#0 has the 32-bitE Xbinary form 101010....10 or 2863311530 decimal, while #0c/#65535 = cI X0101....01 binary = 1431655765 decimal, and #255c/#255 is equivalent ton X#65535. XmK XThe select operator takes from the first operand whichever bits correspondVO Xto 1's in the second operand, and packs these bits as the right in the result.tI XBoth operands are automatically padded on the left with zeros to 32 bits.J Xbefore the selection takes place, so the variable types are unrestricted.K XIf more than 16 bits are selected, the result is a 32-bit value, otherwiseRN Xit is a 16-bit value. For example, #179~#201 (binary value 10110011~11001001)K Xselects from the first argument the 8th, 7th, 4th, and 1st from last bits,RM Xnamely, 1001, which = 9. But #201~#179 selects from binary 11001001 the 8th,wL X6th, 5th, 2nd, and 1st from last bits, giving 10001 = 17. #179~#179 has the, Xvalue 31, while #201~#201 has the value 15. XmL XPerhaps a simpler way of understanding the operation of the select operatorN Xwould be to examine the logic diagram on the following page (Figure 1), whichM Xperforms the select operation upon two 8-bit values, A and B. The gates usedlI Xare Warmenhovian logic gates, which means the outputs have four possibleIH Xvalues: low, high, undefined (value of an uninitialized flip-flop), andI Xoscillating (output of a NOR gate with one input low and the other inputaL Xconnected to the output). These values are represented symbolically by '0',H X'1', '2', and 'F'. Note in particular that, while NOT-0 is 1 and NOT-2 G Xis 0 as in two-valued logic, NOT-? is ? and NOT-F is F. The functions g, Xof the various gates are listed on Table 1. Xr X Xd Xe Xi Xy X  X3.4.2 UNARY OPERATORS XlJ XThe unary operators are & (logical AND), V (logical OR), and V- (logicalH XXOR). This last character is obtained by overpunching a worm (-) on a VD X(V).  The operator is inserted between the spot, two-spot, mesh, orC Xwhat-have-you, and the integer, thus: .&123, #V123. Multiple unaryaI Xoperators may not be concatenated, thus the form #V&123 is invalid. ThiseL Xwill be covered later when precedence is discussed. These operators performG Xtheir respective logical operations on all pairs of adjacent bits, the L Xresult from the first and last bits going into the first bit of the result.F XThe effect is that of rotating the operand one place to the right andF XANDing, ORing, or XORing with its initial value. Thus, #&77 (binary =K X1001101) is binary 0000000000000100 = 4, #V77 is binary 1000000001101111 = 4 X32879, and #V77 is binary 1000000001101011 = 32875. Xs X3.4.3 PRECEDENCE. Xt' XPrecedence of operators is as follows:( Xt Xn X6 Xr Xh X) Xh X  Xl X  X @ X                                                            [1]6 X(The remainder of this page intentionally left blank) Xi Xe Xo X  Xt X  Xu X  X  X	 X( XN X  X_________________C X1) Keep in mind that the aim in designing INTERCAL was to have no O X   precedents.: X- X X~ X5 X$ X" X5K XThis precedence (or lack thereof) may be overruled by grouping expressions I Xbetween pairs of sparks (') or rabbit-ears ("). Thus '#165c/#203'~#358 5C X(binary value '10100101c11001011'~101100110) has the value 15, but"H X#165c/'#203~#358' has the value 34815, and #165c/#203~#358 is invalidJ Xsyntax and is completely valueless (except perhaps as an educational toolM Xto the programmer). A unary operator is applied to a sparked or rabbit-eared M Xexpression by inserting the operator immediately following the opening spark K Xor ears. Thus, the invalid expression #V&123, which was described earlier,RE Xcould be coded as 'V#&123' or 'V"&#123"'. Note: In the interests of sN Xsimplifying the sometimes overly-complex form of expressions, INTERCAL allowsJ Xa spark-spot combination ('.) to be replaced with a wow (!). Thus '.1~.2'B Xis equivalent to !1~.2', and 'V.1c.2' is equivalent to "V!1c.2'". X K XCombining a rabbit-ears with a spot to form a rabbit (V) is not permitted,iJ Xalthough the programmer is free to use it should he find an EBCDIC reader0 Xwhich will properly translate a 12-3-7-8 punch. XhF XSparks and/or rabbit-ears must also be used to distinguish among suchI Xotherwise ambiguous subscripted and multiply-subscripted expressions as:  Xk X	,1 SUB #1 ~ #2 X	,1 SUB ,2 SUB #1 #2 #3+ X	,1 SUB " ,2 SUB " ,3 SUB #1 " #2 " " #3 "  X K XThe third case may be isolated into either of its possible interpretations!J Xby simply changing some pairs of rabbit-ears to sparks, instead of addingL Xmore ears (which would only confuse the issue further). Ambiguous cases areF Xdefined as those for which the compiler being used finds a legitimateL Xinterpretation which is different from that which the user had in mind. See Xalso section 8.1. Xe Xe Xn X  Xw Xo X4. STATEMENTS XT@ XIn this section is described the format of INTERCAL statements. Xi X4.1 GENERAL FORMATm XnM XStatements may be entered in 'free format'. That is, more than one statementiJ Xmay occur on a single card, and a statement may begin on one card and endN Xon a later one. Note that if this is done, all intervening cards and portionsO Xthereof must be part of the same statement. That this restriction is necessaryaJ Xis immediately apparent from the following example of what might occur if  Xstatements could be interlaced. Xr. X	DO .1 <- ".1c/'&:51~"#V1c!12~;&75SUB"V'V.1~. X	DO .2 <- '"!1c/"&';V79SUB",&7SUB:173"'~!V9c0 X	.2'c,&1SUB:5~#33578"'"'"~'#65535c/"V'V#&85'"'3 X	#8196'"'~.1"c.2'~'#&5c/"'#1279c/#4351'~#65535"'l XeI XThe above statements are obviously meaningless. (For that matter, so arei Xthe statements  X / X	DO .1 <- ".1c/"&:51~"#V1C!12~;&75SUB"V'V.1~a0 X	.2'C,&1SUB:5~/333578"'"'"~#65535c/"V'V#&85'"'. X	DO .2 <- '"!1c/"&';V79SUB",&7SUB:173"'~!V9c1 X	#8196'"'~.1"c.2'~'#&5c/"'#1279c!4351'~#65535"'g XW# Xbut this is not of interest here.)e XpL XSpaces may be used freely to enhance program legibility (or at least reduceH Xprogram illegibility), with the restriction that no word of a statement5 Xidentifier (see section 4.3) may contain any spaces.w Xp X4.2 LABELSp XiK XA statement may begin with a LOGICAL LINE LABEL enclosed in wax-wane pairssL X(()). A statement may not have more than one label, although it is possibleI Xto omit the label entirely. A line label is any integer from 1 to 65535,iJ Xwhich must be unique within each program. The user is cautioned, however,L Xthat many line labels between 1000 and 1999 are used in the INTERCAL System XLibrary functions.o X  X4.3 IDENTIFIERS AND QUALIFIERSe XrJ XAfter the line label (if any), must follow one of the following statementL Xidentifiers: DO, PLEASE, or PLEASE DO. These may be used interchangeably toJ Ximprove the aesthetics of the program. The identifier is then followed byL Xeither, neither, or both of the following optional parameters (qualifiers):K X(1) either of the character strings NOT or N'T, which causes the statementtF Xto be automatically abstained from (see section 4.4.9) when executionJ Xbegins, and (2) a number between 0 and 100, preceded by a double-oh-sevenJ X(%), which causes the statement to have only the specified percent chanceJ Xof being executed each time it is encountered in the course of execution. Xl X X  Xd Xu Xn Xt X4.4 STATEMENTSo X K XFollowing the qualifiers (or, if none are used, the identifier) must occur3I Xone of the 13 valid operations. (Exception: see section 4.5.) These are A9 Xdescribed individually in sections 4.4.1 through 4.4.13.i Xt X4.4.1 CALCULATE XhJ XThe INTERCAL equivalent of the half-mesh (=) in FORTRAN, BASIC, PL/I, andD Xothers, is represented by an angle (<) followed by a worm (-). ThisL Xcombination is read 'gets'. 32-bit variables may be assigned 16-bit values,H Xwhich are padded on the left with 16 zero bits. 16-bit variables may beF Xassigned 32-bit values only if the value is less than 65535. Thus, to@ Xinvert the least significant bit of the first element of 16-bit/ X2-dimensional array number 1, one could write:e XT. X	,1SUB#1#1 <- 'V,1SUB#1#1c/#1'~'#0c/#65535' XpL XSimilarly to SNOBOL and SPITBOL, INTERCAL uses the angle-worm to define theJ Xdimensions of arrays. An example will probably best describe the format. L XTo define 32-bit array number 7 as 3-dimensional, the first dimension beingK Xseven, the second being the current value of 16-bit variable number seven,rM Xand the third being the current value of the seventh element of 16-bit arraybL Xnumber seven (which is one-dimensional) mingled with the last three bits ofM X32-bit variable number seven, one would write (just before they came to takeb Xhim away):u Xs' X	;7 <- #7 BY .7 BY ",7SUB#7"c/':7~#7't X 2 XThis is, of course, different from the statement: Xi' X	;7 <- #7 BY .7 BY ,7SUB"#7c/':7~#7'"a X K XINTERCAL also permits the redefining of array dimensioning, which is done sM Xthe same way as is the initial dimensioning. All values of items in an array I Xare lost upon redimensioning, unless they have been STASHed (see section1G X4.4.5), in which case restoring them also restores the old dimensions.P Xa X Xm Xr Xy X  Xe X4.4.2 NEXT  XrK XThe NEXT statement is used both for subroutine calls and for unconditionalo* Xtransfers. This statement takes the form: Xe X	DO (label) NEXT  X  X(or, of course, X. X	PLEASE DO (label) NEXT XhL Xetc.), where (label) represents any logical line label which appears in theF Xprogram. The effect of such a statement is to transfer control to theJ Xstatement specified, and to store in a push down list (which is initiallyF Xempty) the location from which the transfer takes place. Items may beE Xremoved from this list and may be discarded or used to return to the I Xstatement immediately following the NEXT statement. These operations arehF Xdescribed in sections 4.4.3 and 4.4.4 respectively. The programmer isK Xgenerally advised to discard any stack entries which he does not intend toOH Xutilize, since the stack has a maximum depth of 79 entries. A program'sI Xattempting to initiate an 80th level of NEXTing will result on the fatal-@ Xerror message, "PROGRAM HAS DISAPPEARED INTO THE BLACK LAGOON." XM
 X4.4.3 FORGET  XeE XThe statement PLEASE FORGET exp, where exp represents any expression H X(except colloquial and facial expressions), causes the expression to beF Xevaluated, and the specified number of entries to be removed from theI XNEXTing stack and discarded. An attempt to FORGET more levels of NEXTingrL Xthan are currently stacked will cause the stack to be emptied, and no errorK Xcondition is indicated. This is because the condition is not considered to0L Xbe an error. As described in section 4.4.2, it is good programming practiceK Xto execute a DO FORGET #1 after using a NEXT statement as an unconditional K Xtransfer, so that the stack does not get cluttered up with unused entries:  X  X	DO (123) NEXT  X	.  X	.  X  (123) DO FORGET #1  X 
 X4.4.4 RESUMEh XeK XThe statement PLEASE RESUME exp has the same effect as FORGET, except that L Xprogram control is returned to the statement immediately following the NEXTL Xstatement which stored in the stack the last entry to be removed. Note thatK Xa rough equivalent of the FORTRAN computed GO TO and BASIC ON exp GO TO is % Xperformed by a sequence of the form:t Xr
 X	DO (1) NEXT6 X	.2 X	.3 X    (1) DO (2) NEXT X	PLEASE FORGET #1 X	.1 X	.a X    (2) DO RESUME .1# XcN XUnlike the FORGET statement, an attempt to RESUME more levels of NEXTing thanF Xbeen stacked will cause program termination. See also section 4.4.11. Xg Xm X4.4.5 STASH XaK XSince subroutines are not explicitly implemented in INTERCAL, the NEXT andeG XRESUME statements must be used to execute common routines. However, asiG Xthese routines might use the same variables as the main program, it is#I Xnecessary for them to save the values of any variables whose values theysG Xalter, and later restore them. This process is simplified by the STASHnF Xstate ment, which has the form DO STASH list, where list represents aJ Xstring of one or more variable or array names, separated by intersections
 X(+). Thus Xt X	PLEASE STASH .123+:123+,123r XtI Xstashes the values of two variables and one entire array. The values areeN Xleft intact, and copies thereof are saved for later retrieval by (what else?)H Xthe RETRIEVE statement (see section 4.4.6). It is not possible to STASH Xsingle array items. Xu X4.4.6 RETRIEVEi X M XPLEASE RETRIEVE list restores the previously STASHed values of the variablesBJ Xand arrays named in the list. If a value has been stashed more than once,K Xthe most recently STASHed values are RETRIEVEd, and a second RETRIEVE willaH Xrestore the second most recent values STASHed. Attempting to RETRIEVE aJ Xvalue which has not been STASHed will result in the error message, "THROW XSTICK BEFORE RETRIEVING." Xr
 X4.4.7 IGNOREs XfJ XThe statement DO IGNORE list causes all subsequent statements to have no K Xeffect upon variables and/or arrays named in the list. Thus, for example, t Xafter the sequencet X 
 X	DO .1 <- #1L X	PLEASE IGNORE .1
 X	DO .1 <- #0t XdG X16-bit variable number 1 would have the value 1, not 0. Inputting (seegK Xsection 4.4.12) into an IGNOREd variable also has no effect. The condition L Xis annulled via the REMEMBER statement (see section 4.4.8). Note that, whenC Xa variable is being IGNOREd, its value, though immutable, is stille/ Xavailable for use in expressions and the like.a Xi X4.4.8 REMEMBERa XeK XPLEASE REMEMBER list terminates the effect of the IGNORE statement for all L Xvariables and/or arrays named in the list. It does not matter if a variableL Xhas been IGNOREd more than once, nor is it an error if the variable has not Xbeen IGNOREd at all.r Xb X4.4.9 ABSTAIN X.I XINTERCAL contains no simple equivalent to an IF statement or computed GOVJ XTO, making it difficult to combine similar sections of code into a singleG Xroutine which occasionally skips around certain statements. The IGNORE'J Xstatement (see section 4.4.7) is helpful in some cases, but a more viableF Xmethod is often required. In keeping with the goal of INTERCAL havingI Xnothing in common with any other language, this is made possible via thei XABSTAIN statement.n X3M XThis statement takes on one of two forms. It may not take on both at any one L Xtime. DO ABSTAIN FROM (label) causes the statement whose logical line labelL Xis (label) to be abstained form. PLEASE ABSTAIN FROM gerund list causes all@ Xstatements of the specified type(s) to be abstained from, as in Xi X	PLEASE ABSTAIN FROM STASHING+ X	PLEASE ABSTAIN FROM IGNORING + FORGETTINGt X	PLEASE ABSTAIN FROM NEXTINGt( X     or PLEASE ABSTAIN FROM CALCULATING X D XStatements may also be automatically abstained from at the start of: Xexecution via the NOT or N'T parameter (see section 4.3). XL XEJ XIf, in the course of execution, a statement is encountered which is beingJ Xabstained from, it is ignored and control passes to the next statement in7 Xthe program (unless it, too, is being abstained from).( XeN XThe statement DO ABSTAIN FROM ABSTAINING is perfectly valid, as is DO ABSTAINM XFROM REINSTATING (although this latter is not usually recommended). However,)K Xthe statement DO ABSTAIN FROM GIVING UP is not accepted, even though DON'Ts XGIVE UP is. X  X4.4.10 REINSTATEf X J XThe REINSTATE statement, like the ABSTAIN, takes as an argument either a I Xline label or a gerund list. No other form of argument is permitted. Forg/ Xexample, the following is an invalid argument:f X)$ X	Given: x=/0, y=/0,  Prove: x+y=0. X	Since x=/0, then x+1=/1, x+a=/a, x+y=/y. X	Thus x+y =/ anything but 0./ X	Since x+y cannot equal anything but 0, x+y=0.A X  X								    Q.E.D.i XeE XREINSTATEment nullifies the effects of an abstention. Either form ofsK XREINSTATEment can be used to "free" a statement, regardless of whether thesG Xstatement was abstained from by gerund list, line label, or NOT. Thus,tI XPLEASE REINSTATE REINSTATING is not necessarily an irrelevant statement, L Xsince it might free a DON'T REINSTATE command or a REINSTATE the line labelI Xof which was abstained from. However, DO REINSTATE GIVING UP is invalid,dK Xand attempting to REINSTATE a GIVE UP statement by line label will have notC Xeffect. Note that this insures that DON'T GIVE UP will always be am X"do-nothing" statement. X  X4.4.11 GIVE UPt XsM XPLEASE GIVE UP is used to exit from a program. It has the effect of a PLEASEtM XRESUME #80. DON'T GIVE UP, as noted in section 4.4.10, is effectively a null  Xstatement.r Xa
 X4.4.12 Inputi XtF XInput is accomplished with the statement DO WRITE IN list, where listI Xrepresents a string of variables and/or elements or arrays, separated byiK Xintersections. Numbers are represented on cards, each number on a separate)H Xcard, by spelling out each digit (in English) and separating the digitsI Xwith one or more spaces. A zero (0) may be spelled as either ZERO or OH.aJ XThus the range of (32-bit) input values permissible extends from ZERO (or= XOH) through FOUR TWO NINE FOUR NINE SIX SEVEN TWO NINE FIVE.s X L XAttempting to write in a value greater than or equal to SIX FIVE FIVE THREEL XSIX for a 16-bit variable will result in the error message, "DON'T BYTE OFF XMORE THAN YOU CAN CHEW."r Xy X4.4.13 Output XXK XValues may be output to the printer, one value per line, via the statementtL XDO READ OUT list, where the list contains variables, array elements, and/orL Xconstants.  Output is in the form of "extended" Roman numerals (also called1 X                                               _eM X"butchered" Roman numerals), with an overline ( ) indicating the value beloweI Xis "times 1000", and lower-case letters indicating "times 1000000". ZeroyK Xis indicated by an overline with no character underneath. Thus, the range oE X                                           _         __      _______iK Xof (32-bit) output values possible is from   through ivccxcivCMLXVIICCXCV. H XNote: For values whose residues modulo 1000000 are less than 4000, M isL Xused to represent 1000; for values whose residues are 4000 or greater, I isJ X                                                                       __K Xused. Thus #3999 would read out as MMMIM while #4000 would read out as IV.ON X                                  _                                   _     _N XSimilar rules apply to the use of M and i for 1000000, and to that of m and i Xfor 1000000000. Xo X Xu X  X  Xr Xi
 X4.5 Commentsu XdK XUnrecognizable statements, as noted in section 7, are flagged with a splataH X(*) during compilation, and are not considered fatal errors unless theyL Xare encountered during execution, at which time the statement (as input at K Xcompilation time) is printed and execution is terminated. This allows for  K Xan interesting (and, by necessity, unique) means of including comments in  1 Xan INTERCAL listing. For example, the statement:o Xt+ X*	PLEASE NOTE THAT THIS LINE HAS NO EFFECT  X L Xwill be ignored during execution due to the inclusion of the NOT qualifier.9 XUser-supplied error messages are also easy to implement:S XE$ X*	DO SOMETHING ABOUT OVERFLOW IN ;3 Xx* Xas are certain simple conditional errors: X D X* (123)	DON'T YOU REALIZE THIS STATEMENT SHOULD ONLY BE ENCOUNTERED X		ONCE? X	PLEASE REINSTATE (123) XNJ XThis pair of statements will cause an error exit the second time they areF Xencountered. Caution!! The appearance of a statement identifier in anJ Xintended comment will be taken as the beginning of a new statement. Thus,= Xthe first example on the preceding page could not have been:E XE+ X* 	PLEASE NOTE THAT THIS LINE DOES NOTHINGi XcK XThe third example, however, is valid, despite the appearance of two cases  L Xof D-space-O, since INTERCAL does not ignore extraneous spaces in statement
 Xidentifiers.n X X  Xu X  Xe Xu X5. SUBROUTINE LIBRARY X,G XINTERCAL provides several built-in subroutines to which control can betI Xtransferred to perform various operations. These operations include manytI Xuseful functions which are not easily representable in INTERCAL, such asS Xaddition, subtraction, etc. Xr
 X5.1 Usage X,N XIn general, the operands are .1, .2, etc., or :1, :2, etc., and the result(s)J Xare stored in what would have been the next operand(s). For instance, oneN Xroutine adds .1 to .2 and store the sum in .3, with .4 being used to indicateA Xoverflow. All variables not used for results are left unchanged.l X) X5.2 Available Functions XeN XAt the time of this writing, only the most fundamental operations are offeredL Xin the library, as a more complete selection would require prohibitive timeN Xand coree to implement. These functions, along with their corresponding entry7 Xpoints (entered via DO (entry) NEXT) are listed below.E Xa1 X (1000)	.3 <- .1 plus .2, error exit on overflowt X (1009)	.3 <- .1 plus .2e( X	.4 <- #1 if no overflow, else .4 <- #21 X (1010)	.3 <- .1 minus .2, no action on overflowR0 X (1020)	.1 <- .1 plus #1, no action on overflow2 X (1030)	.3 <- .1 times .2, error exit on overflow X (1039)	.3 <- .1 times .2( X	.4 <- #1 if no overflow, else .4 <- #2 X (1040)	.3 <- .1 divided by .2, X	.3 <- #0 if .2 is #07 X (1050) .2 <- :1 divided by .1, error exit on overflow  X	.2 <- #0 if .1 is #0 X 1 X (1500) :3 <- :1 plus :2, error exit on overflows X (1509) :3 <- :1 plus :2R( X	:4 <- #1 if no overflow, else :4 <- #21 X (1510) :3 <- :1 minus :2, no action on overflows& X (1520) :1 <- .1 concatenated with .28 X (1525) This subroutine is intended solely for internal4 X	use within the subroutine library and is therefore/ X	not described here. Its effect is to shift .3e X	logically 8 bits to the left.  X (1530) :1 <- .1 times .22 X (1540)	:3 <- :1 times :2, error exit on overflow X (1549)	:3 <- :1 times :2( X	:4 <- #1 if no overflow, else :4 <- #2 X (1550)	:3 <- :1 divided by :2G X	:3 <- #0 if :2 is #0 XA3 X (1900)	.1 <- uniform random no. from #1 to #65535o4 X (1910) .2 <- normal random no. from #0 to .1, with, X	      standard deviation .1 divided by #12 Xi X Xr Xi Xw Xh Xc X6. PROGRAMMING HINTSc XaL XFor the user looking to become more familiar with the INTERCAL language, weJ Xpresent in this section an analysis of a complex program, as well as some1 Xsuggested projects for the ambitious programmer.t X H XConsidering the effort involved in writing an INTERCAL program, it was L Xdecided in putting together this manual to use an already existing program K Xfor instructive analysis. Since there was only one such program available, K Xwe have proceeded to use it. It is known as the "INTERCAL System Library."a Xe X6.1 Description XtK XThe program listing begins on the second page following. It is in the sameAI Xformat as would be produced by the Princeton INTERCAL compiler in FORMAT G Xmode with WDITH=62 (see section 8). For a description of the functionsi+ Xperformed by the Library, see section 5.2.i Xv
 X6.2 Analysis' XaH XWe shall not attempt to discuss here the algorithms used, but rather weJ Xshall point out some of the general techniques applicable to a wide range
 Xof problems.t XnG XStatements 10, 14, 15, and 26 make up a virtual "computed GO TO". When(K Xstatement 10 is executed, control passes eventually to statement 16 or 11,AI Xdepending on whether .5 contains #1 or #2, respectively. The value of .5.J Xis determined in statement 9, which demonstrates another handy technique.K XTo turn an expression, exp, with value #0 or #1, into #1 or #2 (for use ineM Xa "GO TO"), use "V'exp'c/#1"~#3. To reverse the condition (i.e., convert #0i0 Xto #2 and leave #1 alone) use "V'exp'c/#2"~#3. XaF XCertain conditions are easily checked. For example, to test for zero,K Xselect the value from itself and select the bottom bit (see statement 54)./L XTo test for all bits being 1's, select the value from itself and select theD Xtop bit (see statement 261). The test to greater than, performed inL Xstatements 192 and 193 on 32-bit values, employs binary logical operations,  Xwhich are performed as follows: Xa X	'V.1c.2'~'#0c/#65535' X ) Xfor 16-bit values or, for 32-bit values:T XE/ X	"'V":1~'#65535c30'"c/":2~'#65535c/#0'"'~'#0e/ X	c/#65535'"c/"'V":1~'#0c/#65535'"c/":2~'#0a X	c/#65535'"'~'#0c/#65535'"l Xo4 X(The proofs are left as an exercise to the reader.) XUL XTesting for greater-than with 16-bit values is somewhat simpler and is done Xwith the pair of statements:h Xt! X	DO .C <- 'V.Ac.B'~'#0c/#65535' + X	DO .C <- '&"'.A~.C'~'"V'V.C~.C'c/#32768"4% X		~"#0c/#65535"'"c/".C~.CZ''ZZZ`#1u X H XThis sets .C (a dummy variable) to #1 if .A > .B, and #0 otherwise. TheI Xexpression may be expanded as described above to instead set .C to #1 or  X#2. X1G XNote also in statement 220 the occurrence of ~"#65535c65535". Although K Xthese operations select the entire value, they are not extraneous, as theyrC Xensure that the forthcoming Vs will be operating on 32-bit values.e XnI XIn several virtual computed GO TOs the DO FORGET #1 (statement 15 in the L Xearlier example) has been omitted, since the next transfer of control wouldJ Xbe a DO RESUME #1.  By making this a DO RESUME #2 instead, the FORGET may Xbe forgotten. XuK XIn statement 64, note that .2 is STASHed twice by a single statement. Thise Xis perfectly legal. XoE XLastly, note in statements 243 and 214 respectively, expressions foriC Xshifting 16- and 32-bit variables logically one place to the left. @ XStatement 231 demonstrates right-shifting for 32-bit variables. Xe& XMIKE GETS TO INSERT THE PROGRAM HERE! X X6.3 Program Listing Xs X    1	(1000)	PLEASE IGNORE .4" X    2		PLEASE ABSTAIN FROM (1005)( X    3	(1009)	DO STASH .1 + .2 + .5 + .6 X    4		DO .4 <- #1  X    5		DO (1004) NEXT X    6	(1004)	PLEASE FORGET #1' X    7		DO .3 <- 'V.1c.2'~'#0c/#65535'h' X    8		DO .6 <- '&.1c.2'~'#0c/#65535'e- X    9		PLEASE DO .5 <- "V!6~#32768'c/#1"~#3y X   10		DO (1002) NEXT X   11		DO .4 <- #2t X   12	(1005)	DO (1006) NEXT1 X*  13	(1999)	DOUBLE OR SINGLE PRECISION OVERFLOW  X   14	(1002)	DO (1001) NEXT X   15	(1006)	PLEASE FORGET #1' X   16		DO .5 <- 'V"!6~.6'~#1"c/#1'~#3N X   17		DO (1003) NEXT X   18		DO .1 <- .3 ' X   19		DO .2 <- !6c/#0'~'#32767c/#1'e X   20		DO (1004) NEXT X   21	(1003)	DO (1001) NEXT X   22		DO REINSTATE (1005) / X   23	(1007)	PLEASE RETRIEVE .1 + .2 + .5 + .6  X   24		DO REMEMBER .4 X   25		PLEASE RESUME #2 X   26	(1001)	DO RESUME .5# X   27	(1010)	DO STASH .1 + .2 + .4  X   28		DO .4 <- .1 - X   29		DO .1 <- 'V.2c/#65535'~'#0c/#65535'  X   30		DO (1020) NEXT X   31		PLEASE DO .2 <- .4 X   32		PLEASE DO (1009) NEXTu  X   33		DO RETRIEVE .1 + .2 + .4 X   34		PLEASE RESUME #1 X   35	(1020)	DO STASH .2 + .3 X   36		DO .2 <- #1a X   37		PLEASE DO (1021) NEXTa X   38	(1021)	DO FORGET #1" X   39		DO .3 <- "V!1~.2'c/#1"~#3. X   40		PLEASE DO .1 <- 'V.1c.2'~'#0c/#65535' X   41		DO (1022) NEXT' X   42		DO .2 <- !2c/#0'~'#32767c/#1'e X   43		DO (1021) NEXT X   44	(1023)	PLEASE RESUME .3 X   45	(1022)	DO (1023) NEXT X   46		PLEASE RETRIEVE .2 + .3g X   47		PLEASE RESUME #2$ X   48	(1030)	DO ABSTAIN FROM (1033)" X   49		PLEASE ABSTAIN FROM (1032) X   50	(1039)	DO STASH :1 + .5 X   51		DO (1530) NEXT X   52		DO .3 <- :1~#65535, X   53		PLEASE DO .5 <- :1~'#65280c/#65280'' X   54		DO .5 <- 'V"!5~.5'~#1"c/#1'~#3a X   55		DO (1031) NEXT X   56	(1032)	DO (1033) NEXT X   57		DO (1999) NEXT X   58	(1031)	DO (1001) NEXT X   59	(1033)	DO .4 <- .5R X   60		DO REINSTATE (1032)r X   61		PLEASE REINSTATE (1033)r X   62		DO RETRIEVE :1 + .5e X   63		PLEASE RESUME #26 X   64	(1040)	PLEASE STASH .1 + .2 + .2 + :1 + :2 + :3 X   65		DO .2 <- #0e X   66		DO (1520) NEXT X   67		DO STASH :1  X   68		PLEASE RETRIEVE .2 X   69		DO .1 <- .2t X   70		DO .2 <- #0	 X   71		PLEASE DO (1520) NEXT  X   72		DO :2 <- :1i  X   73		DO RETRIEVE .1 + .2 + :1 X   74		DO (1550) NEXT X   75		PLEASE DO .3 <- :3  X   76		DO RETRIEVE :1 + :2 + :3 X   77		DO RESUME #1' X   78	(1050)	PLEASE STASH :2 + :3 + .5  X   79		DO :2 <- .1B X   80		PLEASE DO (1550) NEXTv% X   81		DO .5 <- :3~'#65280c/#65280'r' X   82		DO .5 <- 'V"!5~.5'~#1"c/#1'~#3u X   83		DO (1051) NEXT X   84		DO (1999) NEXT X   85	(1051)	DO (1001) NEXT X   86		DO .2 <- :3i$ X   87		PLEASE RETRIEVE :2 + :3 + .5 X   88		DO RESUME #2( X   89	(1500)	PLEASE ABSTAIN FROM (1502)" X   90		PLEASE ABSTAIN FROM (1506); X   91	(1509)	PLEASE STASH :1 + .1 + .2 + .3 + .4 + .5 + .6e X   92		DO .1 <- :1~#65535! X   93		PLEASE DO .2 <- :2~#65535e X   94		DO (1009) NEXT X   95		DO .5 <- .3o X   96		PLEASE DO .6 <- .4% X   97		DO .1 <- :1~'#65280c/#65280')% X   98		DO .2 <- :2~'#65280c/#65280'  X   99		DO (1009) NEXT X  100		DO .1 <- .3a X  101		PLEASE DO (1503) NEXTh X  102		DO .6 <- .4c X  103		DO .2 <- #1l X  104		DO (1009) NEXT X  105		DO .1 <- .3l X  106		DO (1501) NEXT X  107	(1504)	PLEASE RESUME .6 X  108	(1503)	DO (1504) NEXT X  109	(1501)	DO .2 <- .5l) X  110		DO .5 <- 'V"'&.6c.4'~#1"c/#2'~#3e X  111		DO (1505) NEXT X  112	(1506)	DO (1502) NEXT X  113		PLEASE DO (1999) NEXT2 X  114	(1505)	DO (1001) NEXT X  115	(1502)	DO :4 <- .51 X  116		DO (1520) NEXT X  117		DO :3 <- :1 8 X  118		PLEASE RETRIEVE :1 + .1 + .2 + .3 + .4 + .5 + .6 X  119		DO REINSTATE (1502)  X  120		DO REINSTATE (1506)  X  121		PLEASE RESUME #3# X  122	(1510)	DO STASH :1 + :2 + :4 > X  123		DO :1 <- "'V/":2~'#65535c/#0'"c/#65535'~'#0c/#65535 X	    5'"c/"'V":2~'#0c/#65535'"c/#65535'~'#0c65535i X	    '" X  124		DO :2 <- #1: X  125		DO (1509) NEXT X  126		PLEASE RETRIEVE :1 X  127		DO :2 <- :3i X  128		PLEASE DO (1509) NEXT  X  129		DO RETRIEVE :2 + :4d X  130		PLEASE RESUME #1" X  131	(1520)	PLEASE STASH .3 + .4 X  132		DO .3 <- .1~#43690 X  133		DO (1525) NEXT9 X  134		PLEASE DO .4 <- 'V.3c/".2~#43690"'~'#0c/#65535'	 X  135		DO .3 <- .1~#21845 X  136		PLEASE DO (1525) NEXT 9 X  137		DO :1 <- .4c/"'V.3c/".2~#21845"'~'#0c/#65535'") X  138		PLEASE RETRIEVE .3 + .4  X  139		DO RESUME #1B X  140	(1525)	DO .3 <- '"'"'"!3c/#0'~'#32767c/#1'"c/#0'~'#327676 X	    c/#1'"c/#0'~'#16383c/#3'"c/#0'~'#4095c/#15' X  141		PLEASE RESUME #1( X  142	(1530)	DO STASH :2 + :3 + .3 + .5 X  143		DO :1 <- #0  X  144		DO :2 <- .2i X  145		DO .3 <- #1G X  146		DO (1535) NEXT X  147	(1535)	PLEASE FORGET #1" X  148		DO .5 <- "V!1~.3'c/#1"~#3 X  149		DO (1531) NEXT X  150		DO (1500) NEXT X  151		DO :1 <- :3e X  152		PLEASE DO (1533) NEXT # X  153	(1531)	PLEASE DO (1001) NEXTC X  154	(1533)	DO FORGET #1' X  155		DO .3 <- !3c/#0'~'#32767c/#1' > X  156		DO :2 <- ":2~'#0c/#65535'"c/"'":2~'#32767c/#0'"c/# X	    0'~'#32767c/#1'"r) X  157		PLEASE DO .5 <- "V!3~.3'c/#1"~#3u X  158		DO (1532) NEXT X  159		DO (1535) NEXT X  160	(1532)	DO (1001) NEXT) X  161		PLEASE RETRIEVE :2 + :3 + .3 + .5n X  162		DO RESUME #2( X  163	(1540)	PLEASE ABSTAIN FROM (1541) X  164		DO ABSTAIN FROM (1542); X  165	(1549)	PLEASE STASH :1 + :2 + :4 + :5 + .1 + .2 + .5  X  166		DO .1 <- :1~#65535, X  167		PLEASE DO .2 <- :2~'#65280c/#65280'% X  168		DO .5 <- :1~'#65280c/#65280'n X  169		DO (1530) NEXT X  170		DO :3 <- :1  X  171		DO .2 <- :2~#65535 X  172		PLEASE DO (1530) NEXT  X  173		DO :5 <- :1  X  174		DO .1 <- .5q X  175		DO (1530) NEXT X  176		DO :4 <- :1t9 X  177		PLEASE DO :1 <- ":3~'#65280c/#65280'"c/":5~'652p X	    80c/#65280'"s X  178		DO .5 <- ':1~:1'~#1r% X  179		DO .2 <- :2~'#65280c/#65280'  X  180		DO (1530) NEXT, X  181		PLEASE DO .5 <- '"':1~:1'~#1"c.5'~#3 X  182		DO .1 <- :3~#65535 X  183		DO .2 <- #0d X  184		DO (1520) NEXT X  185		PLEASE DO :2 <- :1! X  186		PLEASE DO .1 <- :4~#65535  X  187		DO (1520) NEXT X  188		DO (1509) NEXT" X  189		DO .5 <- !5c/":4~#3"'~#15 X  190		DO :1 <- :3i X  191		DO :2 <- :5  X  192		DO (1509) NEXT( X  193		PLEASE DO .5 <- !5c/"4~#3"'~#63' X  194		DO .5 <- 'V"!5~.5'~#1"c/#1'~#3s X  195		PLEASE RETRIEVE :4 X  196	(1541)	DO :4 <- .5s X  197		DO (1543) NEXT X  198	(1542)	DO (1544) NEXT X  199		PLEASE DO (1999) NEXT  X  200	(1543)	DO (1001) NEXT! X  201	(1544)	DO REINSTATE (1541)n X  202		PLEASE REINSTATE (1542)n3 X  203		PLEASE RETRIEVE :1 + :2 + :5 + .1 + .2 + .5i X  204		DO RESUME #2( X  205	(1550)	DO STASH :1 + :4 + :5 + .5 X  206		DO :3 <- #0 ( X  207		DO .5 <- 'V"':2~:2'~#1"c/#1'~#3 X  208		PLEASE DO (1551) NEXT/ X X# X  X X5 X' X6.4 Programming Suggestions X#I XFor the novice INTERCAL programmer, we provide here a list of suggested e XINTERCAL programming projects:r XeN XWrite an integer exponentiation subroutine.  :1 <- .1 raised to the .2 power. XtK XWrite a double-precision sorting subroutine. Given 32-bit array ;1 of size.M X:1, sort the contents into numerically increasing order, leaving the resultsd Xin ;1.a X)# XGenerate a table of prime numbers.T X K XPut together a floating-point library, using 32-bit variables to represent#I Xfloating-point numbers (let the upper half be the mantissa and the loweroK Xhalf be the characteristic).  The library should be capable of performing tL Xfloating-point addition, subtraction, multiplication, and division, as well# Xas the natural logarithm function.  X L XProgram a Fast Fourier Transform (FFT).  This project would probably entailP Xthe writing of the floating-point library as well as sine and cosine functions. X2* XCalculate, to :1 places, the value of pi. XI X Xm X  X  Xe Xa X7. ERROR MESSAGES XyJ XDue to INTERCAL's implementation of comment lines (see section 4.5), mostL Xerror messages are produced during execution instead of during compilation.O XAll errors except those not causing immediate termination of program executioni Xare treated as fatal. Xe X7.1 FormatT XN1 XAll error messages appear in the following form:s X  X	ICLnnnI (error message)4 X		ON THE WAY TO STATEMENT nnnn0 X		CORRECT SOURCE AND RESUBMIT X+G XThe message varies depending upon the error involved.  For undecodableAG Xstatements the message is the statement itself.  The second line tells'J Xwhich statement would have been executed next had the error not occurred.E XNote that if the error is due to 80 attempted levels of NEXTing, the L Xstatement which would have been executed next need not be anywhere near the Xstatement causing the error.  X 
 X7.2 Messages- X"K XBrief descriptions of the different error types are listed below accordingO Xto message number.6 X/G X    000 An undecodable statement has been encountered in the course ofIE X	execution. Note that keypunching errors can be slightly disastrous,4C X	since if 'FORGET' were misspelled F-O-R-G-E-R, the results would 5D X	probably not be those desired. Extreme misspellings may have even B X	more surprising consequences. For example, misspelling 'FORGET' ) X	R-E-S-U-M-E could have drastic results.1 X)/ X    017 An expression contains a syntax error.	 XA= X    079 Improper use has been made of statement identifiers.# X = X    099 Improper use has been made of statement identifiers.  X	4 X    123 Program has attempted 80 levels of NEXTing. X.H X    129 Program has attempted to transfer to a non-existent line label. X/P X    139 An ABSTAIN or REINSTATE statement references a non-existent line label. X 0 X    182 A line label has been multiply defined. XE4 X    197 An invalid line label has been encountered. X	9 X    200 An expression involves an unidentified variable.  X G X    240 An attempt has been made to give an array a dimension of zero.1 X6K X    241 Invalid dimensioning information was supplied in defining or usingE X	an array.0 X	? X    275 A 32-bit value has been assigned to a 16-bit variable.E X ? X    436 A retrieval has been attempted for an unSTASHed value.	 XAH X    533 A WRITE IN statement or interleave (c) operation has produced a, X	value requiring over 32 bits to represent. X+ X    562 Insufficient data.e X  X    579 Input data is invalid.S XH> X    621 The expression of a RESUME statement evaluated to #0. X.K X    632 Program execution was terminated via a RESUME statement instead ofT
 X	GIVE UP. X G X    633 Execution has passed beyond the last statement of the program.V X19 X    774 A compiler error has occurred (see section 8.1).H X P X    778 An unexplainable compiler error has occurred (see J. Lyon or B. Woods). X~ X Xc X6 X0 X  X				[3] X			TONSIL A X# X X'$ XThe Official INTERCAL Character Set X(H XTabulated on page XX are all the characters used in INTERCAL, exceptingE Xletters and digits, along with their names and interpretations. AlsoAJ Xincluded are several characters not used in INTERCAL, which are presented4 Xfor completeness and to allow for future expansion. X- X~ X5 X  X  X	 XA XD X2 X  X# X3 X  X  X	 X( X9 XE X  X  X	 X. X- Xo X  X6 XL XE X  X< X4 X  X7 XO X  X: X# X8 X/ X_____________________J X3) Since all other reference manuals have Appendices, it was decided thatG Xthe INTERCAL manual should contain some other type of removable organ.  X4- X4) This footnote intentionally unreferenced.	 X( X1 XE X  X1 X(H X_______________________________________________________________________H X|                                                                     |2 X|Character	Name			Use (if any)                  |H X|                                                                     |/ X|    .		spot			identify 16-bit variable      |	3 X|    : 		two-spot		identify 32-bit variable      |1/ X|    ,		tail			identify 16-bit array         |51 X|    ;		hybrid			identify 32-bit array         |A/ X|    #		mesh			identify constant             |3 X|    =		half-mesh					      |0 X|    '		spark			grouper	       	              | X|    `		backspark					      |. X|    !		wow			equivalent to spark-spot      |0 X|    ? 		what			unary exlusive OR (ATARI only)|5 X|    "		rabbit-ears		grouper                       |A2 X|    !`		rabbit			equivalent to ears-spot       |@ X|    |		spike                                                 |7 X|    %  	double-oh-seven		percentage qualifier	      | ( X|    -		worm			used with angles	      |) X|    <		angle			used with worms		      |5  X|    >		right angle					      |. X|    (		wax			precedes line label           |* X|    )		wane			follows line label	      | X|    [		U turn						      |  X|    ]		U turn back					      | X|    {		embrace					 	      | X|    }		bracelet					      | 0 X|    *		splat			flags invalid statements      |0 X|    &		ampersand[5]		unary logical AND	      |% X|    V		V			unary logical OR	      |1 X|    		(or book)					      | / X|    V-		bookworm		unary exclusive OR	      | & X|		(or universal qualifier)			      | X|    $		big money					      |* X|    c|		change			binary mingle		      |) X|    ~		sqiggle			binary select		      |  X|    _		flat worm					      |0 X|    		overline		indicates "times 1000"	      |3 X|    +		intersection		separates list items	      |  X|    /		slat						      | X|    \		backslat					      |	 X|    @		whirlpool					      | X|    -'		hookworm					      |2 X|    ^		shark						      |	' X|    		(or simply sharkfin)				      |S" X|    #I[]		blotch						      |H X|_____________________________________________________________________| X7 XL. X		Table 2 (top view). INTERCAL character set. X-# X__________________________________5 X  X5) Got any better ideas?  X1 X" XNOTES ON THE ATARI IMPLEMENTATION X1I XThe Atari implementation of INTERCAL differs from the original PrincetonEL Xversion primarily in the use of ASCII rather than EBCDIC. Since there is noK X"change" sign (c) in ASCII, we have substituted the "big money" ($) as the:L Xmingle operator. We feel that this correctly represents the increasing costJ Xof software in relation to hardware. (Consider that in 1970 one could getH XRUNOFF for free, to run on a $20K machine, whereas today a not quite asL Xpowerful formatter costs $99 and runs on a $75 machine.)  We also feel thatF Xthere should be no defensible contention that INTERCAL has any sense.F XAlso, since overpunches are difficult to read on the average VDT, theF Xexclusive-or operator may be written ?.  This correctly expresses theL Xaverage person's reaction on first encountering exclusive-or, especially onI Xa PDP-11.  Note that in both of these cases, the over-punched symbol may I Xalso be used if one is masochistic, or concerned with portability to the L XPrinceton compiler.  The correct over-punch for "change" is "c<backspace>/"J Xand the correct over-punch for V is "V<backspace>-".  These codes will beL Xproperly printed if you have a proper printer, and the corresponding EBCDIC> Xcode will be produced by the /IBM option on the LIST command. Xd END-of-intercal.manm echo file: intercal.texe3 sed 's/^X//' >intercal.tex << 'END-of-intercal.tex'e X% -*- Mode: TeX -*-   X% for LaTeX X\documentstyle[ick]{article}  Xe= X\title{                 The INTERCAL Programming Language \\a2 X                                Reference Manual}B X\author{                        Donald R. Woods \& James M. Lyon}G X\date{                Copyright Donald R. Woods \& James M. Lyon 1973}  Xb X\begin{document}h X  X\maketitles X\thispagestyle{empty}	 X\newpagea Xr X\tableofcontentsy X\thispagestyle{empty}	 X\newpage  X\setcounter{page}{1}n Xu X\section{Introduction}, XdI XThe names you are about to ignore are true.  However, the story has beensD Xchanged significantly.  Any resemblance of the programming languageI Xportrayed here to other programming languages, living or dead, is purely  Xcoincidental. X:  X\subsection{Origin and Purpose} XmK XThe INTERCAL programming language was designed the morning of May 26, 1972fH Xby Donald R. Woods and James M. Lyon, at Princeton University.  ExactlyK Xwhen in the morning will become apparent in the course of this manual.  ItiL Xwas inspired by one ambition; to have a compiler language which has nothingF Xat all in common with any other major language.  By 'major' was meantL Xanything with which the authors were at all familiar, e.g., FORTRAN, BASIC,I XCOBOL, ALGOL, SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP, and PI/I. I XFor the most part, INTERCAL has remained true to this goal, sharing onlyoI Xthe basic elements such as variables, arrays, and the ability to do I/O,rD Xand eschewing all conventional operations other than the assignment Xstatement (FORTRAN ``|=|'').i Xw X\subsection{Acronym}  XtK XThe full name of the compiler is ``Compiler Language With No PronounceableaD XAcronym'', which is, for obvious reasons, abbreviated ``INTERCAL''. Xo X\subsection{Acknowledgments}r X J XThe authors are deeply indebted to Eric M. Van and Daniel J. Warmenhoven,E Xwithout whose unwitting assistance this manual would still have been4
 Xpossible. XO XT X Xm Xp Xe X- X- X\section{Fundamental Concepts}b XyK XIn this section an attempt is made to describe how and why INTERCAL may be 5 Xused; i.e., what it is like and what it is good for.- X- X\subsection{Sample Program} X G XShown below is a relatively simple INTERCAL program which will read ineL X32-bit unsigned integers, treat them as signed, 2's-complement numbers, andJ Xprint out their absolute values.  The program exits if the absolute valueI Xis zero.  Note in particular the inversion routine (statements 6 through-F X14), which could be greatly simplified if the subroutine library (see Xsection 5) were used. X K XA more detailed analysis of a program is made in section 6 of this manual.  XaL X\continuationchartrue % sample.i uses the continuation character convention X\ICverbatimlisting{sample.i}  X0 X  X\subsection{Uses For INTERCAL}a XyI XINTERCAL's main advantage over other programming languages is its strictuJ Xsimplicity.  It has few capabilities, and thus there are few restrictionsL Xto be kept in mind.  Since it is an exceedingly easy language to learn, oneL Xmight expect it would be a good language for initiating novice programmers.F XPerhaps surprising, than, is the fact that it would be more likely toL Xinitiate a novice into a search for another line of work.  As it turns out,D XINTERCAL is more useful (which isn't saying much) as a challenge toL Xprofessional programmers.  Those who doubt this need only refer back to theI Xsample program in section 2.1.  This 23-statement program took somewheretL Xfrom 15 to 30 minutes to write, whereas the same objectives can be achieved/ Xby single-statement programs in either SNOBOL;o Xr X\begin{verbatim} ' X        PLEASE INPUT POS(0) ('-' ! '')[( X        + (SPAN('0123456789') $ OUTPUT)' X        + *NE(OUTPUT) :S(PLEASE)F(END)o X\end{verbatim}  X\noindent or APL; XI. X\IConeline{|[1] >\llap -0=\llap /?<\llap -?|} X F XAdmittedly, neither of these is likely to appear more intelligible toH Xanyone unfamiliar with the languages involved, but they took roughly 60J Xseconds and 15 seconds, respectively, to write.  Such is the overwhelming Xpower of INTERCAL!  X K XThe other major importance of INTERCAL lies in its seemingly inexhaustible L Xcapacity for amazing one's fellow programmers, confounding programming shopK Xmanagers, winning friends, and influencing people.  It is a well-known andrK Xoft-demonstrated fact that a person whose work is incomprehensible is held L Xin high esteem.  For example, if one were to state that the simplest way to9 Xstore a value of 65535 in a 32-bit INTERCAL variable is:  X  X\begin{verbatim}| X        DO :1 <- #0?#256f X\end{verbatim} G Xany sensible programmer would say that that was absurd.  Since this is L Xindeed the simplest method, the programmer would be made to look foolish inJ Xfront of his boss, who would of course happened to turn up, as bosses areH Xwont to do.  The effect would be no less devastating for the programmer Xhaving been correct.  X  X X  X  X	 Xl Xe X\section{Description} XaJ XThe examples of INTERCAL programming which have appeared in the precedingK Xsections of this manual have probably seemed highly esoteric to the reader(G Xunfamiliar with the language.  With the aim of making them more so, we ( Xpresent here a description of INTERCAL. X| X| X\subsection{Variables}  X H XINTERCAL allows only 2 different types of variables, the 16-bit integerK Xand the 32-bit integer.  These are represented by a spot (|.|) or two-spotuL X(|:|), respectively, followed by any number between 1 and 65535, inclusive.J XThese variables may contain only non-negative numbers; thus they have theK Xrespective ranges of values: 0 to 65535 and 0 to 4294967295.  Note: |.123|eL Xand |:123| are two distinct variables.  On the other hand, |.1| and |.0001|F Xare identical.  Furthermore, the latter may NOT be written as |1E-3|. X  X\subsection{Constants}  X J XConstants are 16-bit values only and may range from 0 to 65535.  They areL Xprefixed by a mesh (|#|).  Caution! Under no circumstances confuse the meshD Xwith the interleave operator, except under confusing circumstances! X  X\subsection{Arrays} X	L XArrays are represented by a tail (|,|) for 16-bit values, or a hybrid (|;|)H Xfor 32-bit values, followed by a number between 1 and 65535, inclusive.F XThe number is suffixed by the word |SUB|, followed by the subscripts,D Xseparated optionally by spaces.  Subscripts may be any expressions,J Xincluding those involving subscripted variables.  This occasionally leadsG Xto ambiguous constructions, which are resolved as discussed in section J X3.4.3.  Definition of array dimensions will be discussed later in greaterK Xdetail, since discussing it in less detail would be difficult.  As before,LE X|,123| and |;123| are distinct.  In summary, |.123|, |:123|, |#123|,o% X|,123|, and |:123| are all distinct.i Xh X\subsection{Operators}n XCK XINTERCAL recognizes 5 operators---2 binary and 3 unary.  Please be kind to"L Xour operators: they may not be very intelligent, but they're all we've got.J XIn a sense, all 5 operators are binary, as they are all bit-oriented, but< Xit is not our purpose here to quibble about bits of trivia. Xe Xh XJ X% ******* proofread versus the paper copy only this far !!!! ************ X. XW Xl Xf! X\subsubsection{Binary Operators}s XeK XThe binary operators are INTERLEAVE (also called MINGLE) and SELECT, whichuK Xare represented by a change (|\change|) and a sqiggle (|~|), respectively.  XsF XThe interleave operator takes two 16-bit values and produces a 32-bitK Xresult by alternating the bits of the operands.  Thus, |#65535c#0| has the K X32-bit binary form 101010....10 or 2863311530 decimal, while |#0c#65535| =eI X0101....01 binary = 1431655765 decimal, and |#255c#255| is equivalent tor
 X|#65535|. X<K XThe select operator takes from the first operand whichever bits corresponddG Xto 1's in the second operand, and packs these bits as the right in thesJ Xresult.  Both operands are automatically padded on the left with zeros toD X32 bits before the selection takes place, so the variable types areI Xunrestricted.  If more than 16 bits are selected, the result is a 32-bitXI Xvalue, otherwise it is a 16-bit value.  For example, |#179~#201| (binary I Xvalue 10110011|~|11001001) selects from the first argument the 8th, 7th,}G X4th, and 1st from last bits, namely, 1001, which = 9.  But |#201~#179|aG Xselects from binary 11001001 the 8th, 6th, 5th, 2nd, and 1st from last J Xbits, giving 10001 = 17.  |#179~#179| has the value 31, while |#201~#201| Xhas the value 15. X\L XPerhaps a simpler way of understanding the operation of the select operatorH Xwould be to examine the logic diagram on the following page (Figure 1),I Xwhich performs the select operation upon two 8-bit values, A and B.  The K Xgates used are Warmenhovian logic gates, which means the outputs have fourpA Xpossible values: low, high, undefined (value of an uninitializedTI Xflip-flop), and oscillating (output of a NOR gate with one input low and H Xthe other input connected to the output).  These values are representedN Xsymbolically by '|0|', '|1|', '{\tt ?}', and '|F|'.  Note in particular that,O Xwhile NOT-|0| is |1| and NOT-|1| is |0| as in two-valued logic, NOT-{\tt ?} islN X{\tt ?} and NOT-|F| is |F|.  The functions of the various gates are listed in	 XTable 1.a X\stepcounter{table} Xa Xe X XR XN XA X, XC  X\subsubsection{Unary Operators} XSA XThe unary operators are |&| (logical AND), |V| (logical OR), andsL X|\bookworm| (logical XOR).  This last character is obtained by overpunchingG Xa worm (|-|) on a V (|V|).  The operator is inserted between the spot, K Xtwo-spot, mesh, or what-have-you, and the integer, thus: |.&123|, |#V123|.uL XMultiple unary operators may not be concatenated, thus the form |#V&123| isI Xinvalid.  This will be covered later when precedence is discussed. ThesetF Xoperators perform their respective logical operations on all pairs ofL Xadjacent bits, the result from the first and last bits going into the firstL Xbit of the result.  The effect is that of rotating the operand one place toF Xthe right and ANDing, ORing, or XORing with its initial value.  Thus,K X|#&77| (binary = 1001101) is binary 0000000000000100 = 4, |#V77| is binary,I X1000000001101111 = 32879, and |#V77| is binary 1000000001101011 = 32875.} X\typeout{typo here} Xe X\subsubsection{Precedence}r Xw' XPrecedence of operators is as follows:g X, Xe X\vspace{2 in} X\hspace{4 in}I X\footnote{Keep in mind that the aim in designing INTERCAL was to have no 
 Xprecedents.}  X\stepcounter{footnote}u X\vspace{1 in} Xo7 X(The remainder of this page intentionally left blank.)y Xm	 X\newpaget Xs Xo Xn Xi Xr Xs X  Xc Xn X  Xe Xe X  X  X X  Xa Xd Xa XiK XThis precedence (or lack thereof) may be overruled by grouping expressionsr: Xbetween pairs of sparks (|'|) or rabbit-ears (|"|).  ThusJ X|'#165c#203'~#358| (binary value |'|10100101|c|11001011|'~|101100110) has> Xthe value 15, but |#165c'#203~#358'| has the value 34815, andG X|#165c#203~#358| is invalid syntax and is completely valueless (except H Xperhaps as an educational tool to the programmer).  A unary operator isJ Xapplied to a sparked or rabbit-eared expression by inserting the operatorD Ximmediately following the opening spark or ears.  Thus, the invalidD Xexpression |#V&123|, which was described earlier, could be coded asG X|'V#&123'| or |'V"&#123"'|.  Note: In the interests of simplifying thegK Xsometimes overly-complex form of expressions, INTERCAL allows a spark-spoteG Xcombination (|'.|) to be replaced with a wow (|!|).  Thus |'.1~.2'| iseE Xequivalent to |!1~.2'|, and |'V.1c.2'| is equivalent to |"V!1c.2'"|.e XmL XCombining a rabbit-ears with a spot to form a rabbit (|V|\typeout{Rabbit?})K Xis not permitted, although the programmer is free to use it should he find+A Xan EBCDIC reader which will properly translate a 12-3-7-8 punch.E XoF XSparks and/or rabbit-ears must also be used to distinguish among suchI Xotherwise ambiguous subscripted and multiply-subscripted expressions as:o Xi X\begin{verbatim}  X        ,1 SUB #1 ~ #2a X        ,1 SUB ,2 SUB #1 #2 #3o2 X        ,1 SUB " ,2 SUB " ,3 SUB #1 " #2 " " #3 " X\end{verbatim}h XvK XThe third case may be isolated into either of its possible interpretations J Xby simply changing some pairs of rabbit-ears to sparks, instead of addingI Xmore ears (which would only confuse the issue further).  Ambiguous caseslJ Xare defined as those for which the compiler being used finds a legitimateH Xinterpretation which is different from that which the user had in mind. XSee also section 8.1. Xt Xs Xl X  X  X  X\section{Statements}  Xa@ XIn this section is described the format of INTERCAL statements. X1 X\subsection{General Format} XaF XStatements may be entered in ``free format.''  That is, more than oneL Xstatement may occur on a single card, and a statement may begin on one cardJ Xand end on a later one.  Note that if this is done, all intervening cardsD Xand portions thereof must be part of the same statement.  That thisL Xrestriction is necessary is immediately apparent from the following example7 Xof what might occur if statements could be interlaced.p Xe X\begin{verbatim} 3 X        DO .1 <- ".1c'&:51~"#V1c!12~;&75SUB"V'V.1~e3 X        DO .2 <- '"!1c"&';V79SUB",&7SUB:173"'~!V9c.5 X        .2'c,&1SUB:5~#33578"'"'"~'#65535c"V'V#&85'"'r6 X        #8196'"'~.1"c.2'~'#&5c"'#1279c#4351'~#65535"' X\end{verbatim} J XThe above statements are obviously meaningless.  (For that matter, so are Xthe statements  Xs X\begin{verbatim}y4 X        DO .1 <- ".1c"&:51~"#V1C!12~;&75SUB"V'V.1~5 X        .2'C,&1SUB:5~/333578"'"'"~#65535c"V'V#&85'"'e3 X        DO .2 <- '"!1c"&';V79SUB",&7SUB:173"'~!V9ch6 X        #8196'"'~.1"c.2'~'#&5c"'#1279c!4351'~#65535"' X\end{verbatim}6# Xbut this is not of interest here.)  X L XSpaces may be used freely to enhance program legibility (or at least reduceH Xprogram illegibility), with the restriction that no word of a statement5 Xidentifier (see section 4.3) may contain any spaces.a X  X\subsection{Labels} XeK XA statement may begin with a LOGICAL LINE LABEL enclosed in wax-wane pairshF X(|()|).  A statement may not have more than one label, although it isL Xpossible to omit the label entirely.  A line label is any integer from 1 toI X65535, which must be unique within each program.  The user is cautioned,eE Xhowever, that many line labels between 1000 and 1999 are used in thef# XINTERCAL System Library functions.d Xt( X\subsection{Identifiers and Qualifiers} XrJ XAfter the line label (if any), must follow one of the following statement@ Xidentifiers: |DO|, |PLEASE|, or |PLEASE DO|.  These may be usedJ Xinterchangeably to improve the aesthetics of the program.  The identifierG Xis then followed by either, neither, or both of the following optionalf Xparameters (qualifiers):3 X\begin{enumerate}Q X\item either of the character strings |NOT| or |N'T|, which causes the statementiF Xto be automatically abstained from (see section 4.4.9) when execution Xbegins, and@ X\item a number between 0 and 100, preceded by a double-oh-sevenL X(|%|), which causes the statement to have only the specified percent chanceJ Xof being executed each time it is encountered in the course of execution. X\end{enumerate} X. X Xh X X% X* X* X\subsection{Statements}   XyK XFollowing the qualifiers (or, if none are used, the identifier) must occuraI Xone of the 13 valid operations.  (Exception: see section 4.5.) These areE9 Xdescribed individually in sections 4.4.1 through 4.4.13.a Xi X\subsubsection{Calculate} X L XThe INTERCAL equivalent of the half-mesh (|=|) in FORTRAN, BASIC, PL/I, andI Xothers, is represented by an angle (|<|) followed by a worm (|-|).  This-G Xcombination is read ``gets.''  32-bit variables may be assigned 16-bit J Xvalues, which are padded on the left with 16 zero bits.  16-bit variablesK Xmay be assigned 32-bit values only if the value is less than 65535.  Thus,iC Xto invert the least significant bit of the first element of 16-bits/ X2-dimensional array number 1, one could write:u Xa X\begin{verbatim}h1 X        ,1SUB#1#1 <- 'V,1SUB#1#1c#1'~'#0c#65535'  X\end{verbatim}h XaL XSimilarly to SNOBOL and SPITBOL, INTERCAL uses the angle-worm to define theJ Xdimensions of arrays.  An example will probably best describe the format.L XTo define 32-bit array number 7 as 3-dimensional, the first dimension beingK Xseven, the second being the current value of 16-bit variable number seven,0G Xand the third being the current value of the seventh element of 16-bitrJ Xarray number seven (which is one-dimensional) mingled with the last threeH Xbits of 32-bit variable number seven, one would write (just before they Xcame to take him away): Xp X\begin{verbatim}o, X        ;7 <- #7 BY .7 BY ",7SUB#7"c':7~#7' X\end{verbatim}w2 XThis is, of course, different from the statement: Xs X\begin{verbatim}g, X        ;7 <- #7 BY .7 BY ,7SUB"#7c':7~#7'" X\end{verbatim}  XeJ XINTERCAL also permits the redefining of array dimensioning, which is doneH Xthe same way as is the initial dimensioning.  All values of items in anI Xarray are lost upon redimensioning, unless they have been |STASH|ed (see C Xsection 4.4.5), in which case restoring them also restores the oldl Xdimensions. XN X Xi X1 Xn XO X1 X\subsubsection{Next}e Xo? XThe |NEXT| statement is used both for subroutine calls and for 9 Xunconditional transfers.  This statement takes the form:e Xa$ X\IConeline{|DO ({\em label}) NEXT|} Xu
 X\noindent X(or, of course,+ X\IConeline{|PLEASE DO ({\em label}) NEXT|}) XV
 X\noindentE Xetc.), where |({\em label})| represents any logical line label whichbG Xappears in the program.  The effect of such a statement is to transferwL Xcontrol to the statement specified, and to store in a push down list (whichF Xis initially empty) the location from which the transfer takes place.K XItems may be removed from this list and may be discarded or used to returnsD Xto the statement immediately following the |NEXT| statement.  TheseH Xoperations are described in sections 4.4.3 and 4.4.4 respectively.  TheK Xprogrammer is generally advised to discard any stack entries which he does J Xnot intend to utilize, since the stack has a maximum depth of 79 entries.J XA program's attempting to initiate an 80th level of |NEXT|ing will resultE Xon the fatal error message, ``PROGRAM HAS DISAPPEARED INTO THE BLACK 
 XLAGOON.'' X1 X\subsubsection{Forget}o XrH XThe statement |PLEASE FORGET| {\em exp}, where {\em exp} represents anyB Xexpression (except colloquial and facial expressions), causes theF Xexpression to be evaluated, and the specified number of entries to beH Xremoved from the |NEXT|ing stack and discarded.  An attempt to |FORGET|L Xmore levels of |NEXT|ing than are currently stacked will cause the stack toF Xbe emptied, and no error condition is indicated.  This is because theL Xcondition is not considered to be an error.  As described in section 4.4.2,J Xit is good programming practice to execute a |DO FORGET #1| after using aJ X|NEXT| statement as an unconditional transfer, so that the stack does not& Xget cluttered up with unused entries: X  X\begin{verbatim}n X        DO (123) NEXT
 X        .
 X        . X  (123) DO FORGET #1t X\end{verbatim}A Xa X\subsubsection{Resume}t X I XThe statement |PLEASE RESUME| {\em exp} has the same effect as |FORGET|,fE Xexcept that program control is returned to the statement immediately&K Xfollowing the |NEXT| statement which stored in the stack the last entry to3J Xbe removed.  Note that a rough equivalent of the FORTRAN computed |GO TO|I Xand BASIC |ON| {\em exp} |GO TO| is performed by a sequence of the form:b Xe X\begin{verbatim}| X        DO (1) NEXT
 X        .
 X        . X    (1) DO (2) NEXT X        PLEASE FORGET #1e
 X        .
 X        . X    (2) DO RESUME .1o X\end{verbatim}t XoE XUnlike the |FORGET| statement, an attempt to |RESUME| more levels of F X|NEXT|ing than been stacked will cause program termination.  See also Xsection 4.4.11. XS Xk X\subsubsection{Stash} XlI XSince subroutines are not explicitly implemented in INTERCAL, the |NEXT|mK Xand |RESUME| statements must be used to execute common routines.  However, J Xas these routines might use the same variables as the main program, it isI Xnecessary for them to save the values of any variables whose values theynJ Xalter, and later restore them.  This process is simplified by the |STASH|G Xstate ment, which has the form |DO STASH| {\em list}, where {\em list}cI Xrepresents a string of one or more variable or array names, separated byc Xintersections (|+|).  Thusd X  X\begin{verbatim}r$ X        PLEASE STASH .123+:123+,123 X\end{verbatim} J Xstashes the values of two variables and one entire array.  The values areG Xleft intact, and copies thereof are saved for later retrieval by (what.J Xelse?)  the |RETRIEVE| statement (see section 4.4.6).  It is not possible Xto |STASH| single array items.e Xs X\subsubsection{Retrieve}g XcI X|PLEASE RETRIEVE| {\em list} restores the previously |STASH|ed values oftA Xthe variables and arrays named in the list.  If a value has beenuL Xstashed more than once, the most recently |STASH|ed values are |RETRIEVE|d,C Xand a second |RETRIEVE| will restore the second most recent values J X|STASH|ed.  Attempting to |RETRIEVE| a value which has not been |STASH|edE Xwill result in the error message, ``THROW STICK BEFORE RETRIEVING.''& XB X\subsubsection{Ignore}' X1I XThe statement |DO IGNORE| {\em list} causes all subsequent statements to2J Xhave no effect upon variables and/or arrays named in the list.  Thus, for Xexample, after the sequence Xa X\begin{verbatim}  X        DO .1 <- #1 X        PLEASE IGNORE .1& X        DO .1 <- #0 X\end{verbatim}.H X16-bit variable number 1 would have the value 1, not 0.  Inputting (seeD Xsection 4.4.12) into an |IGNORE|d variable also has no effect.  TheH Xcondition is annulled via the |REMEMBER| statement (see section 4.4.8).L XNote that, when a variable is being |IGNORE|d, its value, though immutable,8 Xis still available for use in expressions and the like. Xs X\subsubsection{Remember}s XiC X|PLEASE REMEMBER| {\em list} terminates the effect of the |IGNORE|aJ Xstatement for all variables and/or arrays named in the list.  It does notK Xmatter if a variable has been |IGNORE|d more than once, nor is it an error / Xif the variable has not been |IGNORE|d at all.i Xg X\subsubsection{Abstain} XuL XINTERCAL contains no simple equivalent to an |IF| statement or computed |GOK XTO|, making it difficult to combine similar sections of code into a singleyJ Xroutine which occasionally skips around certain statements.  The |IGNORE|J Xstatement (see section 4.4.7) is helpful in some cases, but a more viableG Xmethod is often required.  In keeping with the goal of INTERCAL having I Xnothing in common with any other language, this is made possible via they X|ABSTAIN| statement.t XfJ XThis statement takes on one of two forms.  It may not take on both at anyF Xone time.  |DO ABSTAIN FROM ({\em label})| causes the statement whoseE Xlogical line label is |({\em label})| to be abstained form.  |PLEASEeG XABSTAIN FROM| {\em gerund list} causes all statements of the specifiedd$ Xtype(s) to be abstained from, as in Xs X\begin{verbatim}l% X        PLEASE ABSTAIN FROM STASHINGn2 X        PLEASE ABSTAIN FROM IGNORING + FORGETTING$ X        PLEASE ABSTAIN FROM NEXTING( X        PLEASE ABSTAIN FROM CALCULATING X\end{verbatim}l Xi XtD XStatements may also be automatically abstained from at the start of> Xexecution via the |NOT| or |N'T| parameter (see section 4.3). Xr X J XIf, in the course of execution, a statement is encountered which is beingJ Xabstained from, it is ignored and control passes to the next statement in7 Xthe program (unless it, too, is being abstained from).  X|I XThe statement |DO ABSTAIN FROM ABSTAINING| is perfectly valid, as is |DOv? XABSTAIN FROM REINSTATING| (although this latter is not usuallyeI Xrecommended).  However, the statement |DO ABSTAIN FROM GIVING UP| is noto* Xaccepted, even though |DON'T GIVE UP| is. Xt X\subsubsection{Reinstate}H X\newlength{\QEDlen}\settowidth{\QEDlen}{Q.E.D.}\newlength{\lastlinelen}M X\settowidth{\lastlinelen}{Since $x+y$ cannot equal anything but 0, $x+y=0$.}#& X\addtolength{\lastlinelen}{-1\QEDlen} XyK XThe |REINSTATE| statement, like the |ABSTAIN|, takes as an argument eithernH Xa line label or a gerund list.  No other form of argument is permitted.3 XFor example, the following is an invalid argument:d X\begin{quote}7 X        Given: $x\neq0$, $y\neq0$,  Prove: $x+y=0$. \\aF X        Since $x\neq0$, then $x+1\neq1$, $x+a\neq a$, $x+y\neq y$. \\+ X        Thus $x+y \neq$ anything but 0. \\i= X        Since $x+y$ cannot equal anything but 0, $x+y=0$. \\- X	\hspace*{\lastlinelen} Q.E.D.u X\end{quote} XfH X|REINSTATE|ment nullifies the effects of an abstention.  Either form ofK X|REINSTATE|ment can be used to ``free'' a statement, regardless of whethereG Xthe statement was abstained from by gerund list, line label, or |NOT|.YF XThus, |PLEASE REINSTATE REINSTATING| is not necessarily an irrelevantL Xstatement, since it might free a |DON'T REINSTATE| command or a |REINSTATE|K Xthe line label of which was abstained from.  However, |DO REINSTATE GIVING,L XUP| is invalid, and attempting to |REINSTATE| a |GIVE UP| statement by lineH Xlabel will have no effect.  Note that this insures that |DON'T GIVE UP|+ Xwill always be a ``do-nothing'' statement.m X  X\subsubsection{Give Up} XaI X|PLEASE GIVE UP| is used to exit from a program.  It has the effect of aaF X|PLEASE RESUME #80|.  |DON'T GIVE UP|, as noted in section 4.4.10, is Xeffectively a null statement. Xl X\subsubsection{Input} X I XInput is accomplished with the statement |DO WRITE IN| {\em list}, wherepG X{\em list} represents a string of variables and/or elements or arrays,nK Xseparated by intersections.  Numbers are represented on cards, each number K Xon a separate card, by spelling out each digit (in English) and separatingyI Xthe digits with one or more spaces.  A zero (0) may be spelled as either E X|ZERO| or |OH|.  Thus the range of (32-bit) input values permissiblenI Xextends from |ZERO| (or |OH|) through |FOUR TWO NINE FOUR NINE SIX SEVEN  XTWO NINE FIVE|. XtG XAttempting to write in a value greater than or equal to |SIX FIVE FIVE K XTHREE SIX| for a 16-bit variable will result in the error message, ``DON'Ti# XBYTE OFF MORE THAN YOU CAN CHEW.''e Xt X\subsubsection{Output}s X,K XValues may be output to the printer, one value per line, via the statementoC X|DO READ OUT| {\em list}, where the list contains variables, array I Xelements, and/or constants.  Output is in the form of ``extended'' RomansF Xnumerals (also called ``butchered'' Roman numerals), with an overlineE X(\zero) indicating the value below is ``times 1000'', and lower-case H Xletters indicating ``times 1000000''.  Zero is indicated by an overlineI Xwith no character underneath.  Thus, the range of (32-bit) output valuescH Xpossible is from \zero\ through \=i\=vccxciv\=C\=M\=L\=X\=V\=I\=ICCXCV.H XNote: For values whose residues modulo 1000000 are less than 4000, M isK Xused to represent 1000; for values whose residues are 4000 or greater, \=ItL Xis used.  Thus |#3999| would read out as MMMIM while |#4000| would read outL Xas \=I\=V.  Similar rules apply to the use of \=M and i for 1000000, and to$ Xthat of \=m and \=i for 1000000000.8 X\typeout{Do they really mean MMMIM and not MMMCMXCIX??} X  X Xa XF XE Xf Xe X\subsection{Comments} XiK XUnrecognizable statements, as noted in section 7, are flagged with a splatcJ X(|*|) during compilation, and are not considered fatal errors unless theyK Xare encountered during execution, at which time the statement (as input atsK Xcompilation time) is printed and execution is terminated.  This allows for1J Xan interesting (and, by necessity, unique) means of including comments in2 Xan INTERCAL listing.  For example, the statement: X\ X\begin{verbatim} 1 X*       PLEASE NOTE THAT THIS LINE HAS NO EFFECTM X\end{verbatim} L Xwill be ignored during execution due to the inclusion of the NOT qualifier.9 XUser-supplied error messages are also easy to implement:b Xt X\begin{verbatim}i* X*       DO SOMETHING ABOUT OVERFLOW IN ;3 X\end{verbatim}m* Xas are certain simple conditional errors: XH X\begin{verbatim} D X* (123) DON'T YOU REALIZE THIS STATEMENT SHOULD ONLY BE ENCOUNTERED X                ONCE? X        PLEASE REINSTATE (123)  X\end{verbatim}tJ XThis pair of statements will cause an error exit the second time they areH Xencountered.  Caution!!  The appearance of a statement identifier in anK Xintended comment will be taken as the beginning of a new statement.  Thus,r= Xthe first example on the preceding page could not have been:  XS X\begin{verbatim}\0 X*       PLEASE NOTE THAT THIS LINE DOES NOTHING X\end{verbatim} J XThe third example, however, is valid, despite the appearance of two casesF Xof |D|-space-|O|, since INTERCAL does not ignore extraneous spaces in Xstatement identifiers.  X XA X  Xg Xa Xy X\section{Subroutine Library}e XeG XINTERCAL provides several built-in subroutines to which control can be J Xtransferred to perform various operations.  These operations include manyI Xuseful functions which are not easily representable in INTERCAL, such asV Xaddition, subtraction, etc. Xl X\subsection{Usage}m X L XIn general, the operands are |.1|, |.2|, etc., or |:1|, |:2|, etc., and theG Xresult(s) are stored in what would have been the next operand(s).  ForRH Xinstance, one routine adds |.1| to |.2| and store the sum in |.3|, withJ X|.4| being used to indicate overflow.  All variables not used for results Xare left unchanged. X ! X\subsection{Available Functions}e XhF XAt the time of this writing, only the most fundamental operations areC Xoffered in the library, as a more complete selection would requireeL Xprohibitive time and coree to implement.  These functions, along with theirL Xcorresponding entry points (entered via |DO ({\em entry}) NEXT|) are listed Xbelow.B X  X\begin{verbatim}i1 X (1000) .3 <- .1 plus .2, error exit on overflowG X (1009) .3 <- .1 plus .2m/ X        .4 <- #1 if no overflow, else .4 <- #2o1 X (1010) .3 <- .1 minus .2, no action on overflowi0 X (1020) .1 <- .1 plus #1, no action on overflow2 X (1030) .3 <- .1 times .2, error exit on overflow X (1039) .3 <- .1 times .2/ X        .4 <- #1 if no overflow, else .4 <- #2| X (1040) .3 <- .1 divided by .2t X        .3 <- #0 if .2 is #0s7 X (1050) .2 <- :1 divided by .1, error exit on overflow} X        .2 <- #0 if .1 is #0p Xe1 X (1500) :3 <- :1 plus :2, error exit on overflow| X (1509) :3 <- :1 plus :2m/ X        :4 <- #1 if no overflow, else :4 <- #2u1 X (1510) :3 <- :1 minus :2, no action on overflowe& X (1520) :1 <- .1 concatenated with .28 X (1525) This subroutine is intended solely for internal; X        use within the subroutine library and is thereforeL7 X        not described here.  Its effect is to shift .3s& X        logically 8 bits to the left. X (1530) :1 <- .1 times .22 X (1540) :3 <- :1 times :2, error exit on overflow X (1549) :3 <- :1 times :2/ X        :4 <- #1 if no overflow, else :4 <- #2w X (1550) :3 <- :1 divided by :2e X        :3 <- #0 if :2 is #0. XP3 X (1900) .1 <- uniform random no. from #1 to #65535t4 X (1910) .2 <- normal random no. from #0 to .1, with3 X              standard deviation .1 divided by #12B X\end{verbatim}N X  X X  XE X  XT X  X\section{Programming Hints} X L XFor the user looking to become more familiar with the INTERCAL language, weJ Xpresent in this section an analysis of a complex program, as well as some1 Xsuggested projects for the ambitious programmer.a XeH XConsidering the effort involved in writing an INTERCAL program, it was L Xdecided in putting together this manual to use an already existing program L Xfor instructive analysis.  Since there was only one such program available,N Xwe have proceeded to use it.  It is known as the ``INTERCAL System Library.'' Xi X\subsection{Description}T XNL XThe program listing begins on the second page following.  It is in the sameI Xformat as would be produced by the Princeton INTERCAL compiler in FORMATUH Xmode with WDITH=62 (see section 8).  For a description of the functions+ Xperformed by the Library, see section 5.2.t Xd X\subsection{Analysis} X$H XWe shall not attempt to discuss here the algorithms used, but rather weJ Xshall point out some of the general techniques applicable to a wide range
 Xof problems.a XnL XStatements 10, 14, 15, and 26 make up a virtual ``computed |GO TO|''.  WhenK Xstatement 10 is executed, control passes eventually to statement 16 or 11,xJ Xdepending on whether |.5| contains |#1| or |#2|, respectively.  The valueG Xof |.5| is determined in statement 9, which demonstrates another handy L Xtechnique.  To turn an expression, {\em exp}, with value |#0| or |#1|, intoI X|#1| or |#2| (for use in a ``|GO TO|''), use |"V'{\em exp}'c#1"~#3|.  ToeL Xreverse the condition (i.e., convert |#0| to |#2| and leave |#1| alone) use X|"V'{\em exp}'c#2"~#3|. XsG XCertain conditions are easily checked.  For example, to test for zero,lK Xselect the value from itself and select the bottom bit (see statement 54).eL XTo test for all bits being 1's, select the value from itself and select theE Xtop bit (see statement 261).  The test to greater than, performed inSL Xstatements 192 and 193 on 32-bit values, employs binary logical operations,  Xwhich are performed as follows: Xe X\begin{verbatim}  X        'V.1c.2'~'#0c#65535'w X\end{verbatim}`) Xfor 16-bit values or, for 32-bit values:o Xi X\begin{verbatim}E2 X        "'V":1~'#65535c30'"c":2~'#65535c#0'"'~'#0. X        c#65535'"c"'V":1~'#0c#65535'"c":2~'#0  X        c#65535'"'~'#0c#65535'" X\end{verbatim}y4 X(The proofs are left as an exercise to the reader.) XtL XTesting for greater-than with 16-bit values is somewhat simpler and is done Xwith the pair of statements:a Xs X\begin{verbatim} & X        DO .C <- 'V.Ac.B'~'#0c#65535'0 X        DO .C <- '&"'.A~.C'~'"V'V.C~.C'c#32768"/ X                ~"#0c#65535"'"c".C~.CZ''ZZZ`#1  X\end{verbatim}rE XThis sets |.C| (a dummy variable) to |#1| if |.A| $>$ |.B|, and |#0| I Xotherwise.  The expression may be expanded as described above to insteads Xset |.C| to |#1| or |#2|. XrJ XNote also in statement 220 the occurrence of |~"#65535c65535"|.  AlthoughK Xthese operations select the entire value, they are not extraneous, as theyEE Xensure that the forthcoming |V|s will be operating on 32-bit values.  XTM XIn several virtual computed |GO TO|s the |DO FORGET #1| (statement 15 in the L Xearlier example) has been omitted, since the next transfer of control wouldP Xbe a |DO RESUME #1|.  By making this a |DO RESUME #2| instead, the |FORGET| may Xbe forgotten. XtN XIn statement 64, note that .2 is |STASH|ed twice by a single statement.  This Xis perfectly legal. X(E XLastly, note in statements 243 and 214 respectively, expressions forlC Xshifting 16- and 32-bit variables logically one place to the left.e@ XStatement 231 demonstrates right-shifting for 32-bit variables. Xv( X% MIKE GETS TO INSERT THE PROGRAM HERE! X X\subsection{Program Listing}C X L X\continuationchartrue % syslib.i uses the continuation character convention X\ICverbatimlisting{syslib.i} + X\typeout{Where's line 1551?  1900?  1910?}  X XT X  X9 X  Xl% X\subsection{Programming Suggestions}  XdI XFor the novice INTERCAL programmer, we provide here a list of suggested   XINTERCAL programming projects:1 X0R XWrite an integer exponentiation subroutine.  |:1 <- .1| raised to the |.2| power. XfI XWrite a double-precision sorting subroutine.  Given 32-bit array |;1| ofeL Xsize |:1|, sort the contents into numerically increasing order, leaving the Xresults in |;1|.s Xl# XGenerate a table of prime numbers.c XoK XPut together a floating-point library, using 32-bit variables to representnI Xfloating-point numbers (let the upper half be the mantissa and the lowersL Xhalf be the characteristic).   The library should be capable of performing L Xfloating-point addition, subtraction, multiplication, and division, as well# Xas the natural logarithm function.w X M XProgram a Fast Fourier Transform (FFT).   This project would probably entailuP Xthe writing of the floating-point library as well as sine and cosine functions. XD, XCalculate, to |:1| places, the value of pi. Xm X Xr Xe Xi Xi Xe X\section{Error Messages}\ XiJ XDue to INTERCAL's implementation of comment lines (see section 4.5), mostL Xerror messages are produced during execution instead of during compilation.O XAll errors except those not causing immediate termination of program execution  Xare treated as fatal. Xh X\subsection{Format} Xn1 XAll error messages appear in the following form:  Xt X\begin{verbatim}e  X        ICLnnnI (error message)- X                ON THE WAY TO STATEMENT nnnnn, X                CORRECT SOURCE AND RESUBMIT X\end{verbatim}  XSG XThe message varies depending upon the error involved.  For undecodableeG Xstatements the message is the statement itself.  The second line tellsiJ Xwhich statement would have been executed next had the error not occurred.G XNote that if the error is due to 80 attempted levels of |NEXT|ing, the L Xstatement which would have been executed next need not be anywhere near the Xstatement causing the error.a X  X\subsection{Messages} X K XBrief descriptions of the different error types are listed below according  Xto message number.e X  X\begin{description} X\def\ttitem#1{\item[{\tt #1}]}| X,L X\ttitem{000} An undecodable statement has been encountered in the course ofM X        execution.  Note that keypunching errors can be slightly disastrous, L X        since if `|FORGET|' were misspelled F-O-R-G-E-R, the results would L X        probably not be those desired.  Extreme misspellings may have even L X        more surprising consequences.  For example, misspelling `|FORGET|' 0 X        R-E-S-U-M-E could have drastic results. Xe4 X\ttitem{017} An expression contains a syntax error. XfB X\ttitem{079} Improper use has been made of statement identifiers. XOB X\ttitem{099} Improper use has been made of statement identifiers. X1; X\ttitem{123} Program has attempted 80 levels of |NEXT|ing.- X M X\ttitem{129} Program has attempted to transfer to a non-existent line label.i X Y X\ttitem{139} An |ABSTAIN| or |REINSTATE| statement references a non-existent line label.- X 5 X\ttitem{182} A line label has been multiply defined.e X29 X\ttitem{197} An invalid line label has been encountered.) X > X\ttitem{200} An expression involves an unidentified variable. X-L X\ttitem{240} An attempt has been made to give an array a dimension of zero. X P X\ttitem{241} Invalid dimensioning information was supplied in defining or using X        an array. XrD X\ttitem{275} A 32-bit value has been assigned to a 16-bit variable. X F X\ttitem{436} A retrieval has been attempted for an un|STASH|ed value. XdL X\ttitem{533} A |WRITE IN| statement or interleave (|\change|) operation has6 Xproduced a value requiring over 32 bits to represent. X.  X\ttitem{562} Insufficient data. Xl$ X\ttitem{579} Input data is invalid. X)G X\ttitem{621} The expression of a |RESUME| statement evaluated to |#0|.  X R X\ttitem{632} Program execution was terminated via a |RESUME| statement instead of X        |GIVE UP|.# X L X\ttitem{633} Execution has passed beyond the last statement of the program. Xa> X\ttitem{774} A compiler error has occurred (see section 8.1). XdU X\ttitem{778} An unexplainable compiler error has occurred (see J. Lyon or B. Woods).t X\end{description} Xo X Xo Xc< X\section*{Tonsil\footnote{Since all other reference manualsH Xhave Appendices, it was decided that the INTERCAL manual should containN Xsome other type of removable organ.} A:  The Official INTERCAL Character Set} Xr Xn Xn XT XA XrH XTabulated on page 18 are all the characters used in INTERCAL, exceptingF Xletters and digits, along with their names and interpretations.  AlsoJ Xincluded are several characters not used in INTERCAL, which are presented4 Xfor completeness and to allow for future expansion. X\stepcounter{footnote}l9 X\footnotetext{This footnote intentionally unreferenced.}a X F X{\catcode`.=\active \catcode`|=12  % Use . instead of | for code mode1 X\def.{\bgroup\tt\usespecials\def.{\null\egroup}}c X\begin{table}: X\begin{minipage}{\textwidth} % so the footnote works out. X\begin{tabular}{|r|l|p{3in}|} X\hline % XCharacter &	Name &			Use (if any) \\u X\hliner4 X.\spot.	&	spot &			identify 16-bit variable      \\3 X.:.	&	two-spot &		identify 32-bit variable      \\S. X.,.	&	tail &			identify 16-bit array	      \\/ X.;.	&	hybrid &		identify 32-bit array	      \\u+ X.\#.	&	mesh &			identify constant	      \\6 X.=.	&	half-mesh &					      \\.# X.'.	&	spark &			grouper			      \\y X.`.	&	backspark &					      \\n/ X.!.	&	wow &			equivalent to spark-spot      \\d4 X\verb|?|&	what &			unary exlusive OR (ASCII)     \\( X.".	&	rabbit-ears &		grouper			      \\8 X{\verb|!`|}&	rabbit &		equivalent to ears-spot	      \\" X{\verb+|+}&	spike &						      \\7 X.\%.	&	double-oh-seven &	percentage qualifier	      \\x) X.-.	&	worm &			used with angles	      \\a* X.<.	&	angle &			used with worms		      \\! X.>.	&	right angle &					      \\n+ X.(.	&	wax &			precedes line label	      \\ + X.).	&	wane &			follows line label	      \\a X.[.	&	U turn &					      \\! X.].	&	U turn back &					      \\e X.\{.	&	embrace &					      \\ X.\}.	&	bracelet &					      \\31 X.*.	&	splat &			flags invalid statements      \\w< X.\&.	&	ampersand\footnotemark & unary logical AND 	      \\/ X.V.	&	V (or book) &		unary logical OR	      \\1M X.\bookworm. &	bookworm (or universal qualifier) & unary exclusive OR      \\#3 X.\$.	&	big money &		binary mingle (ASCII)	      \\"- X.\change.&	change &		binary mingle		      \\~, X.\~{}.	&	sqiggle &		binary select		      \\  X.\_.	&	flat worm &					      \\7 X.\zero.	&	overline &		indicates ``times 1000''      \\ 4 X.+.	&	intersection &		separates list items	      \\ X./.	&	slat &							\\ X{\verb|\|}&	backslat &						\\' X.@.	&	whirlpool &					      \\&& X.\hookworm.& hookworm &					       \\4 X{\verb|^|}&	shark (or simply sharkfin) &			      \\  X.\blotch.&	blotch						      \\ X\hline# X\end{tabular} X\catcode`.=121 X\caption{		  INTERCAL character set (top view).}r- X\typeout{What does Rabbit really look like?}2( X\def\thempfootnote{\arabic{mpfootnote}}3 X\footnotetext[\thefootnote]{Got any better ideas?}a X\label{character-set} X\end{minipage}o X\end{table} X} XE X X\section*{Tonsil B: i# XNotes On The Atari Implementation}a XsI XThe Atari implementation of INTERCAL differs from the original Princeton J Xversion primarily in the use of ASCII rather than EBCDIC.  Since there isG Xno ``change'' sign (|\change|) in ASCII, we have substituted the ``bigeC Xmoney'' (|$|) as the mingle operator.  We feel that this correctly D Xrepresents the increasing cost of software in relation to hardware.H X(Consider that in 1970 one could get RUNOFF for free, to run on a \$20KH Xmachine, whereas today a not quite as powerful formatter costs \$99 andJ Xruns on a \$75 machine.)  We also feel that there should be no defensibleE Xcontention that INTERCAL has any sense.  Also, since overpunches areCG Xdifficult to read on the average VDT, the exclusive-or operator may beoL Xwritten ?.  This correctly expresses the average person's reaction on firstI Xencountering exclusive-or, especially on a PDP-11.  Note that in both ofd@ Xthese cases, the over-punched symbol may also be used if one isK Xmasochistic, or concerned with portability to the Princeton compiler.  Thea- Xcorrect over-punch for ``change'' is ``c{\sc K X$\langle$backspace$\rangle$}/'' and the correct over-punch for |\bookworm| H Xis "V{\sc $\langle$backspace$\rangle$}-".  These codes will be properlyH Xprinted if you have a proper printer, and the corresponding EBCDIC code= Xwill be produced by the |/IBM| option on the |LIST| command.a Xs X\end{document}f Xt END-of-intercal.text echo file: intercal.styn3 sed 's/^X//' >intercal.sty << 'END-of-intercal.sty'  X% -*- Mode: TeX -*- a X% for LaTeX XnI X% This is the file ick.sty:  macros for typesetting the INTERCAL Manual.  Xl X\setlength{\textwidth}{6.5in}  X\setlength{\oddsidemargin}{0in}! X\setlength{\evensidemargin}{0in}o X\setlength{\textheight}{9in}i X\setlength{\topmargin}{0in} X\setlength{\headsep}{0in} X\setlength{\headheight}{0in}o X1L X%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% X% SPECIAL INTERCAL CHARACTERS X% Xt X% Save ``regular'' characters.  X\def\backslat{\backslash} X\def\embrace{\verb|{|}t X\def\bracelet{\verb|}|} X\def\doubleohseven{\%}e X\def\ampersand{\&}i X\def\sqiggle{\~{}}o X\def\bigmoney{\$} X\def\shark{\verb|^|}. X\def\flatworm{\verb|_|} X\def\mesh{\#}
 X\def\spot{.}r
 X\def\what{?}n Xo< X% \newcommand{\mathify}[1]{\ifmmode{#1}\else\mbox{$#1$}\fi}# X% \def\bookworm{\mathify{\forall}}E X\def\bookworm{\rlap V-} X\def\change{\rlap c/} X%\def\altchange{\rlap /c} X\def\zero{\={}} X\def\spike{\verb+|+}e X\def\althookworm{-\llap '}l X\def\hookworm{'\llap -}% X\def\blotch{\#\llap I\llap [\llap ]}l X  XlL X%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% X% INTERCAL CODE ENVIRONMENT X% X0- X% Just surround the code with vertical bars.t Xi Xw6 X\catcode`|=\active  %  The `|' is active from now on. X\def|{\ifmmode\vert%t8 X        \else\bgroup\tt\usespecials\def|{\null\egroup}%
 X        \fi}f XeF X% To get backslat, embrace, or bracelet in a | | environment, use the X% respective macros.e? X% I might want to translate $ and ? as in the verbatim macros.a X\def\activatespecials{% X  \catcode`\%=\active X  \catcode`\&=\active X  \catcode`\~=\active X  \catcode`\$=\active X  \catcode`\^=\active X  \catcode`\_=\active X  \catcode`\#=\active}  Xl X{% Add new comment charactero X \catcode`+=14e X \activatespecialsa X \gdef\usespecials{+  X  \activatespecials X  \def%{\doubleohseven}+g X  \def&{\ampersand}+R X  \def~{\sqiggle}+  X  \def${\bigmoney}+ X  \def^{\shark}+p X  \def_{\flatworm}+ X  \def#{\mesh}}}t Xm> X% Typeset a one-line INTERCAL example.  This is pretty gross.S X\def\IConeline#1{\vspace\topsep\par\noindent{\tt\ \ \ \ \ \ \ \ }#1\vspace\topsep}  Xg X L X%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% X% VERBATIM FILE LISTING X% XiC X% --- The macros are based on those distributed with Sunil Podar'se: X% --- `EPIC.STY' macro package, attributed to Tim Morgan,D X% --- modified to keep internal macros internal by Adrian F. Clark, X% --- alien@uk.ac.essex.ese5 X% --- ---and further latexification by Chris Rowley,i$ X% --- ca_rowley@uk.ac.open.acs.vax.7 X% And finally, modified for INTERCAL by Michael Ernst.  X   X\def\verbatimfile#1{\begingroup< X                    \@verbatim \frenchspacing \@vobeyspaces' X                    \input#1 \endgroups X} Xs X\newcounter{lineno} Xl X\newif\ifcontinuationcharG X% Say \continuationchartrue if the ends of continued program lines areW X% flagged by slash-newline.G X% This implementation doesn't allow backslashes elsewhere; it would be I X% better to make \, clobbered by \@verbatim, the escape character again,aH X% and then define a whole wad of escape sequences, with \^^M being one. Xu X\newif\ifnonumber Xt X\def\activateverbspecials{% X  \catcode`$=\activeU X  \catcode`?=\active} X  X{\activateverbspecials\ X \catcode`|=0 X \catcode`\\=\active  X |gdef|useverbspecials{%r X  |def\{|nonumbertrue}% X  |def${|change}% X  |def?{|bookworm}% X  |activateverbspecials}} Xe1 X\def\ICverbatimlisting#1{\setcounter{lineno}{0}% H X    \begingroup \@verbatim \frenchspacing \@vobeyspaces \parindent=20pt( X    \everypar{\ifnonumber\nonumberfalse X		\else\stepcounter{lineno}%t@ X                     \llap{{\footnotesize\rm\thelineno\ \ \ }}% X		\fi}%. X    \ifcontinuationchar\catcode`\\=\active\fi X    \useverbspecialsb
 X    \input#11 X    \endgroup X} Xs END-of-intercal.styc echo file: BUGSa# sed 's/^X//' >BUGS << 'END-of-BUGS'  X		NEW FEATURES IN C-INTERCALe XrP X1. As a convenience to all you junior birdmen out there, `NINER' is accepted as+ X   a synonym for `NINE' in INTERCAL input.n X{: X2. The COME FROM statement is now compiled. You may write Xn X   PLEASE COME FROM (n) c XeM X   and the effect will be that whenever execution reaches statement label n,lG X   it will immediately transfer control to the statement following theoN X   COME FROM. Conditional COME FROM is possible; ABSTAIN FROM COMING FROM andK X   REINSTATE COMING FROM are both valid. DON'T COME FROM is a no-op (untiliJ X   reinstated). Finally; NEXTING to the label `target' of an un-abstainedO X   COME FROM *will* cause control to be transferred to the statement following  X   the COME FROM. X	 X			BUGS XsD X1) INTERCAL would be intrinsically a crock even if it worked right. XrM X2) The INTERCAL-72 handling of invalid statements isn't implemented; insteadaM X   they raise a normal compile-time error. This is because I haven't figuredrI X   out how to force YACC to do the needed thing yet. It means C-INTERCALsI X   can't compile the INTERCAL-72 system library yet. Isn't compatibility L X   wonderful? I may have to go to a handcrafted LL(1) parser to fix this... X.F X3) Error-checking could be improved. Not all the errors listed in theN X   manual are actually detected (of those listed in lose.h, E123, E621, E632,N X   E562, E579, E436, E017, E275, E182, E129, E139, and E778 are implemented).P X   In this respect C-INTERCAL follows nobly in the tradition of many production X   compilers. XaL X4) Proper C code is generated for array operations, but the runtime-libraryL X   hooks for the dynamic memory management needed to make the code work areJ X   stubbed out. I'm poor at array-bashing. Rachel Millian has promised to( X   implement this for the next release. XhO X5) The Roman-numeral output from INTERCAL isn't quite as butchered as it ought.P X   to be, because neither I nor the implementor could figure out what the frotzL X   the note in the INTERCAL-72 manual about modulo 4000 and I and M and all X   that was reallyb