VoidLang

From Esolang
Jump to navigation Jump to search

A stack-based language. It supports eval, user input, loops, and basic math. It was designed by iovoid.

Operators

  • " starts and end pushing to stack
  • ! prints the first element of stack, deleting it
  • * multiply the two first elements of stack, deleting the originals
  • / will divide the first element of stack with the seccond, deleting the originals
  • + will add two first elements of stack, deleting the originals
  • - will remove the first element of stack with the seccond, deleting the originals
  • [ starts a loop
  • ] ends a loop
  • ~ breaks from a loop
  • ? break if the first element of stack is 0
  • # break if the length of stack is 1 or 0
  • . pop first element of the stack
  • % adds a random item to the stack, from 1 to 255
  • $ push the length of the stack
  • _ replace first item of stack with it converted to a string, if impossible return the original
  • & eval the concatenation of all elements in the stack, replaces stack with output
  • , take a line of input from stdin
  • ; does nothing
  • ^ push the program code to the stack
  • | actually print the output (! is still needed)
  • = end the program

Examples

Hello, World!
"Hello, World!"[#!]

What's done here? First, " opens the pushing of items to stack (H,e,l,l,o,...), later " closes it. Inside a loop, every item of the stack is printed until its empty.

Other Hello World!
"89"*_!"ello World!/"[!#]

Here, the / is purposefully eaten by [!#] that will ignore the last character

REPL (Read-Eval-Print Loop)
,&[#!]$^&

Here, input is asked with , and then & evals it. Later a [!#] prints everything, like in Hello, World!.

Cat program
,[#!]$^&

^& will repeat the program by eval-ing itself

Quine
^[#!]

Implementations

In Node.JS, by iovoid: https://gist.github.com/io4/c82798e6dfd918e37fe11f67283184a7