TriINTERCAL

TriINTERCAL is an esoteric programming language created by Louis Howell in 1991 as a more difficult version of INTERCAL. It uses ternary instead of binary, and introduces the logical BUT operation.

TriINTERCAL programs are distinguished from INTERCAL programs by the filename extension; .3i (as opposed to .i). There is often no other way to tell them apart, because BUT and sharkfin aren't really that useful and so are not often used, and INTERCAL programs don't necessarily specify constants above 59048.

Ternary logic
TriINTERCAL differs from INTERCAL only in the width of the data types (one-spot data types are 10 trits wide and two-spot data types are 20 trits wide), and in the operators available in expressions. AND and OR are generalizations of the INTERCAL binary versions, BUT is new, and sharkfin and what are two different interpretations of XOR (both of which are available in TriINTERCAL). Mingle mingles trits, rather than bits, whereas select ANDs the two original numbers, then sorts all the bits in the first number corresponding to 2s in the second number to the least significant end, 0s in the second number to the most significant end, and 1s in between them.

AND, OR, mingle, and select operate just like their binary counterparts if no trits with the value 2 are present.

Examples
The following program is valid INTERCAL and TriINTERCAL; it outputs II if compiled as INTERCAL and III if compiled as TriINTERCAL. DO .1 <- #1 $ #0 DO READ OUT .1 PLEASE GIVE UP (This program is right on the boundary as far as politeness is concerned; any more polite and it would be too polite.)

The following program reads in (or WRITES IN) a twospot number, and then outputs the result of applying all 5 ternary logical operations to it: DO WRITE IN :1 DO :2 <- :&1 PLEASE READ OUT :2 DO :2 <- :V1 PLEASE READ OUT :2 DO :2 <- :@1 DO READ OUT :2 DO :2 <- :^1 DO READ OUT :2 DO :2 <- :?1 DO READ OUT :2 PLEASE GIVE UP When given the input ONE TWO THREE FOUR FIVE SIX SEVEN, this program gives the following output: _          LMMDCCCLVII __________       mclxMMMDCCCLIVDCCVIII _______   mclxMMCCCXVXLV _____________        mclxMMMDCCCXXVIIIDCCXCVII ______     mclxMMMCCXMMCIX (This sort of thing explains why a wimpmode option was added to some INTERCAL compilers; the same wimpmode is often present in TriINTERCAL compilers (indeed, they are often the same compilers).)

In wimpmode, the output looks like this (with the input 1234567): 52857 1163854708 1162315045 1163828797 1163212109 which, unfortunately, is still unintelligible in decimal. So in ternary: 3r00000000002200111200 3r10000002222221111221 3r10000000002201111101 3r10000002221121222021 3r10000001210022000222 (here, the input is the same value, now written 3r00000002022201111201.)

External resources

 * The original Usenet post

Also see External INTERCAL resources.