Qwhy

From Esolang
Jump to navigation Jump to search

Qwhy is a fungeoid esolang by User:BoundedBeans that aims to be different than other fungeoids, while also being weird.

Playfield

The default playfield is laid out as in Funge-98, but it doesn't expand infinitely. The number of lines specified in the program is the total default length, though this can be expanded during execution. The longest line is the width of every line, and this cannot be expanded.

Upon reaching the edge of the playfield, the instruction pointer will jump to the nearest J instruction from the point before it went off the playfield.

The playfield can be self-modified, but only by removing the top line or appending a line to the bottom.

The instruction pointer can only move diagonally. It starts at the top right and moves southeast.

The playfield uses 16-bit unsigned integers as its contents, and the Unicode values are what matters to the instruction performed. However, only plain 7-bit ASCII characters may actually be specified, the rest must be created through adding lines.

Queue

Instead of having a stack, Qwhy has a queue. The queue can hold 16-bit unsigned integers.

Instructions

1 Enqueue a 1.
+ Dequeue x and y, enqueue x + y.
- Dequeue x and y, enqueue x - y.
* Dequeue x and y, enqueue x * y.
/ Dequeue x and y, enqueue x / y.
$ Dequeue x.
: Dequeue x, enqueue x twice.
\ Dequeue x and y, enqueue y and x.
; Dequeue x, enqueue x.
r Change the direction to northwest.
7 Change the direction to northeast.
L Change the direction to southwest.
j Change the direction to southeast.
% Skip the next instruction.
x Go in a random diagonal direction.
X Dequeue x, if nonzero, go northwest, if zero, go southeast.
t Dequeue x, if nonzero, go southwest, if zero, go northeast.
G Dequeue x and y, enqueue the number at that position. Note that the numbers accessed will move up one y coordinate if you remove lines.
P Dequeue n numbers, where n is the width of the lines. Add a new line to the in-memory code with that as the contents.
# Remove the top line from the in-memory code.
[ Dequeue numbers until a zero is encountered, inserting them into a list. Use that list as an ID for an iris, the Qwhy version of Funge-98's fingerprint feature. This overloads commands 65500 to 65535. This means you will have to add lines dynamically to even use these instructions at all. There is no iris stack, meaning you cannot have overloading like you can with fingerprints. Also, you cannot unload an iris, it stays forever unless you load a different iris.
] Dequeue x, print it as a Unicode character.
{ Enqueue the Unicode value of a character of input.
_ Halt.

Note that, much like a bishop in chess, it's impossible for the instruction pointer to move on half of the cells. This makes them a great place to store data by self-modification, since they'll never mess any code up no matter how close they are to it.

Examples

Print "HI"

1   j
 1 7 *
  * + :
   : ; ]
    * 1 1
     : : +
      * r ]
       7   _