Haifuckqueue

From Esolang
Jump to navigation Jump to search

haifuckqueue is a stack-based esolang created by User:4gboframram in September 2021. It is inspired by the concept of the traditional Japanese poem, the Haiku. However, programs in this language do not actually look like Haikus but follow a similar form.

Language Formatting

  • Programs are split into chunks of 3 lines of code called stanzas
  • The first line of the stanza must be 5 characters in length, the second must be 7 characters, and the third must be 5 characters long. Depending on the implementation, there may be an enforced newline between stanzas, which is recommended.

The Stack

  • The stack is a finite, array that does not change in length during runtime.
  • Depending on the implementation, each item on the stack is at least 2 bytes signed.


Syntax

Haifuckqueue has a set of operations. These operations can take in a single argument, which is always a number, or have no arguments. Arguments are placed after the operation. Here is the list of operations and descriptions:

Symbol Arguments Effect
+ None Adds the top 2 items on the stack and sets the 3rd item to be the result.
- None Subtracts the top 2 items on the stack and sets the 3rd item to be the result.
* None Multiplies the top 2 items on the stack and sets the 3rd item to be the result. May cause overflow depending on implementation
/ None Floor divides the top 2 items on the stack and sets the 3rd item to be the result.
~ None Sets the top item of the stack to the bitwise inverse of the top item of the stack
& None Takes the bitwise and of the top 2 items on the stack and sets the 3rd item to be the result.
^ None Takes the bitwise xor of the top 2 items on the stack and sets the 3rd item to be the result.
o None Takes the bitwise or of the top 2 items on the stack and sets the 3rd item to be the result.
| Number Sets the top item of the stack to be the value of Number
$ Number Print the top Number items on the stack as their character.
d Number Print the Numberth item on the stack as a digit.
c Number Print value of Numberth item on the stack as a character
s Number Swap the item on top of the stack and the Numberth item on the stack
. Number Jumps to Numberth line if the top of the stack is not zero
! None Sets every item on the stack to 0
# None Pops the top item on the stack.
) None Increments the top item on the stack
( None Decrements the top item on the stack
a None Sets to top item on the stack to the next byte of the input
p None Pushes a 0 on top of the stack

There are also variable numbers that change based on the program state.

  • @ - The number of non-zero items on the stack
  • A - The number of bytes in the input arguments, including the separating null bytes

Strings can be made with this syntax {Chars}

  • Creating a string sets the top {length of Chars} to be the ascii values of string
  • For example, {Hel} sets a stack that starts as 0 0 0 0 0 to 72 101 108 0 0

Examples

Hello World! (with trailing newline)

{Hel}
$3{lo }
$3{W}
$1{o}
$1{rld}
$3{!}
$1|10
$1ooooo
ooooo 

Here, since there needed to be more characters to fit the stanza, there are redundant or operations at the end.

Fibonacci (up to implementation's stack item size)

|1s2+
+s3s2d1
.2+++ 

External Resources