Tri
Jump to navigation
Jump to search
Tri is an esoteric programming language by User:Madk. The language is named for the number of symbols in all its keywords.
Commands
Tri has 70 keywords, a [...] function to set the contents of a cell, and a (...) function to output a string to the console. Anything that is not a command is ignored by the interpreter.
end quit the program abruptly nxt moves the cell pointer to the right lst moves the cell pointer to the left org move the cell pointer to 0 inc increment a cell's value dec decrement a cell's value zro set a cell's value to 0 one set a cell's value to 1 =pi set a cell's value to pi =e= set a cell's value to e fc1 set a cell's value to the first Feigenbaum constant fc2 set a cell's value to the second Feigenbaum constant ape set a cell's value to Apéry's constant gld set a cell's value to the Golden ratio emc set a cell's value to the Euler-Mascheroni constant lpl set a cell's value to the Laplace limit prb set a cell's value to the Parabolic constant mlc set a cell's value to Mill's constant [...] set a cell's value to the number specified inside out output the cell's value as a number inp input the cell's value as a number prn output the cell as an ASCII character lin output a newline to the console stk output the entire numerical contents of the stack to the console str output the entire contents of the stack as ASCII characters (...) output the text inside to the console psh push the cell under the pointer's value onto the stack pop pop the stack's topmost value into this cell and remove it sto pop the stack's topmost value into this cell, don't remove it rnd adds a random number between 0 and 1 to the end of the stack add add the numbers on the stack together sub subtract the lower numbers on the stack from the topmost mul multiply the numbers on the stack together div divide the topmost number on the stack by the others pwr raises the topmost number to the powers of the rest of the stack max removes all but the greatest number from the stack min removes all but the least number from the stack sgn all values on the stack >0 become 1 and <0 become -1 sic increments all stack values by 1 sdc decrements all stack values by 1 mod computes all stack values modulo the value in this cell flr rounds all stack values to the lowest integer cel rounds all stack values to the highest integer rnd rounds all stack values to the nearest integer deg treats all values on the stack as radians and converts to degrees rad treats all values on the stack as degrees and converts to radians sin takes the sine in degrees of all stack values cos takes the cosine in degrees of all stack values tan takes the tangent in degrees of all stack values sec takes the secant in degrees of all stack values csc takes the cosecant in degrees of all stack values cot takes the cotangent in degrees of all stack values exs takes the exsecant in degrees of all stack values asn takes the arcsine in degrees of all stack values vsn takes the versine in degrees of all stack values acs takes the arccosine in degrees of all stack values atn takes the arctangent in degrees of all stack values snh takes the hyperbolic sine of all stack values csh takes the hyperbolic cosine of all stack values tnh takes the hyperbolic tangent of all stack values exp performs the exponential function on all stack values abs takes the absolute value of all stack values neg negates all the stack values log takes the natural logaritm of all stack values and performs binary and on all stack values bor binary or on all stack values xor binary xor on all stack values not binary not on all bits of all stack values 1/x takes the reciprocal of all stack values clr clears the stack trg jump back to the matching jmp jmp jump forward past the matching trg if the current cell is 0 or less // begin and end a comment
Computational class
Tri can be proven as Turing complete because it has a reduction from brainfuck.
All BrainFuck commands relevant to Turing-completeness have equivalents in Tri.
> : nxt < : lst + : inc - : dec [ : jmp ] : trg
Examples
Hello, world!
// Prints "Hello, world!" to the console. // inc inc psh psh psh mul sto nxt sto psh mul lst psh add sto prn nxt zro clr inc inc inc psh psh add inc nxt pop inc psh lst psh mul one psh add sto nxt sto lst lst psh nxt nxt nxt add sto prn zro inc inc inc psh inc psh add sto prn prn inc inc inc prn clr lst lst lst psh nxt psh sub nxt sto inc prn lst one clr inc psh psh inc psh mul nxt psh sub neg pop prn inc nxt psh nxt sto inc inc inc inc inc inc inc inc prn lst prn nxt dec dec dec dec dec prn dec dec dec dec dec dec prn lst dec dec dec dec dec dec dec dec dec dec dec prn lst prn lin // Also prints "Hello, world!" to the console. // (Hello, world!)
99 bottles of beer
// Store 99 bottles of beer on the wall. // incincincincpshincpshpshmulstodecnxtstodec // Repeatedly sing the mundane lyrics for each bottle taken down until 1 remains. // jmpincincout( bottles of beer on the wall.)lin out( bottles of beer.)lin (Take one down, pass it around.)declin out( bottles of beer on the wall.)lindecdectrg // Singular nouns for the win. // incout( bottle of beer on the wall,)lin out( bottle of beer.)lin (Take it down, pass it around.)lin // No more bottles? Saying "Zero" would be awkward. // oneincjmp(No more bottles of beer on the wall.)lindectrg (No more bottles of beer.)lin (Go to the store and buy some more.)lin lstout( bottles of beer on the wall.)lin