In this ReversibleProgrammingLanguage, each command is the reverse of itself. If you run the program forward with 1 input, and then run that output through the program running in reverse order, then you will be back with the input it started with! Interpreter URL: http://zzo38computer.cjb.net/esoteric/revaver ---- It always starts at the line label TERMINATE (.). There can only be 1 of these in the whole program. The TELEPORT (*) command is the only way to jump to another place in the program. The PUSHPOP (;) command pops the top stack value if it is same as it's given parameter, otherwise, it pushes that value. ---- Example: *. . < _1 ;1 < *. Long Text Example: TELEPORT TERM TERMINATE SWAP SUBTRACT 1 PUSHPOP 1 SWAP TELEPORT TERM This example in reverse: TELEPORT TERM SWAP PUSHPOP 1 SUBTRACT 1 SWAP TERMINATE TELEPORT TERM Copying number to other stack example: SWAP PUSHPOP # SWAP And at the end to remove where it used to be (otherwise it would be both places): PUSHPOP # ---- 'Some spelling and grammar issues fixed above -- PhilCooper ---- How would one compute the value of a non one-to-one function (such as "sin x" or "floor x") in such a language? Some possibilities; none seems attractive: * Restrict the domain of such functions such that they ''become'' one-to-one. In other words, I might be able to compute "floor 4.5" and "floor 4.876231", but not both; because "floor^-1 4" needs to have a single unique answer to preserve reversibility. * Disallow non one-to-one functions. * When computing the inverse of a non one-to-one function, use non-determinism to select a possible solution. Redefine "reversibility" to accommodate. * When computing the inverse of a non one-to-one function, return a set of all possible answers. Redefine "reversibility" to accommodate. Ignore (or hand-wave around) the fact that many such sets may be of (uncountably) infinite magnitude. Here is 1 more way: * Return 2 values, for example sin(x) will return sin(x) and int(x/360degrees), and floor(x) will return floor(x) and x-floor(x). Just don't use the value which you don't need. In fact, that last one would be the standard definition of reversible computing, would it not? By definition, you can't throw away information, the best you can do is to make a distinction using some identity; the same way that it might be useful to multiply something by x/x, we do something with 'floor(x) - floor(x)'. -- WilliamUnderwood ---- What are the commands in this language? ---- CategoryProgrammingLanguage