3. DESCRIPTION
The examples of INTERCAL programming which have appeared in the preceding
sections of this manual have probably seemed highly esoteric to the reader
unfamiliar with the language. With the aim of making them more so, we
present here a description of INTERCAL.
3.1 VARIABLES
INTERCAL allows only 2 different types of variables, the 16-bit integer
and the 32-bit integer. These are represented by a spot (.) or two-spot
(:), respectively, followed by any number between 1 and 65535, inclusive.
These variables may contain only non-negative numbers; thus they have the
respective ranges of values: 0 to 65535 and 0 to 4294967295. Note: .123 and
:123 are two distinct variables. On the other hand, .1 and .0001 are
identical. Furthermore, the latter may NOT be written as 1E-3.
3.2 CONSTANTS
Constants are 16-bit values only and may range from 0 to 65535. They are
prefixed by a mesh (#). Caution! Under no circumstances confuse the mesh
with the interleave operator, except under confusing circumstances!
3.3 ARRAYS
Arrays are represented by a tail (,) for 16-bit values, or a hybrid (;) for
32-bit values, followed by a number between 1 and 65535, inclusive. The
number is suffixed by the word SUB, followed by the subscripts, separated
optionally by spaces. Subscripts may be any expressions, including those
involving subscripted variables. This occasionally leads to ambiguous
constructions, which are resolved as discussed in section 3.4.3. Definition
of array dimensions will be discussed later in greater detail, since
discussing it in less detail would be difficult. As before, ,123 and ;123
are distinct. In summary, .123, :123, #123, ,123, and :123 are all
distinct.
3.4 OPERATORS
INTERCAL recognizes 5 operators--2 binary and 3 unary. Please be kind to
our operators: they may not be very intelligent, but they're all we've got.
In a sense, all 5 operators are binary, as they are all bit-oriented, but
it is not our purpose here to quibble about bits of trivia.
3.4.1 BINARY OPERATORS
The binary operators are INTERLEAVE (also called MINGLE) and SELECT, which
are represented by a change (c/) and a sqiggle [sic] (~), respectively.
The interleave operator takes two 16-bit values and produces a 32-bit result
by alternating the bits of the operands. Thus,
#65535c/#0 has the 32-bit
binary form 101010....10 or 2863311530 decimal, while
#0c/#65535 =
0101....01 binary = 1431655765 decimal, and
#255c/#255 is equivalent to
#65535.
The select operator takes from the first operand whichever bits correspond
to 1's in the second operand, and packs these bits to the right in the result.
Both operands are automatically padded on the left with zeros to 32 bits
before the selection takes place, so the variable types are unrestricted.
If more than 16 bits are selected, the result is a 32-bit value, otherwise
it is a 16-bit value. For example, #179~#201 (binary value 10110011~11001001)