WTFZOMFG

From Esolang
Jump to: navigation, search

WTFZOMFG is a language made by Jay Songdahl loosely based on Brainfuck. It is short for "What's That Function? Zen Optimized Malicious File Gophers!"

Syntax

WTFZOMFG is based loosely on Brainfuck. It uses goto statements heavily and compiles to C, then uses your installed C compiler to create the executable. A manual is provided with the download, but all the syntax is listed below.

Control

:<name>  this means GOTO <name>
;<name>  this declares this line as <name>
?<name>  this means, if the cell at the pointer is nonzero, GOTO <name>
!<name>  this means, if the cell at the pointer IS zero, GOTO <name>
(	 if the cell at the pointer is 0, jump to the corresponding ')'
)	 if the cell at the pointer is not 0, jump to the corresponding '('
{	 if the cell at the pointer is 0, jump to the corresponding '}'
}	 (only used with '{')

Cell/Pointer Manipulation

+       this increases the cell at the pointer
-       this decreases the cell at the pointer
|	if the cell at the pointer is 0, set it to 1, otherwise set it to 0
=<n>    this sets the cell at the pointer to n
~<n>    this increases the cell at the pointer by n (use negative to decrease)
&       this copies the cell at the pointer to the next cell to the right
%<n>    this copies the cell at the pointer to cell number <n>
>       this moves the pointer once to the right
<       this moves the pointer once to the left
_<n>    this sets the the pointer to cell number <n>
*<n>    this moves the pointer <n> cells right (negative to go left)
@<c>    subtract the ASCII value of <c> from the cell at the pointer.

Arithmetic

a       add the cell at the pointer to the cell once to the right,
        storing the result to the first cell
s       the same as 'a' but instead of addition, do subtraction
m       the same as a, or s, but multiplication
d       the same as the other three, but division

Input/Output

^       this scans one ASCII character to the cell at the pointer
v       this prints the cell at the pointer as an ASCII character
/       this scans one decimal number to the cell at the pointer
\       this prints the cell at the pointer as a decimal number
.<c>    this prints the character <c> after the period.
'       print up until " symbol

Commenting

#       read the rest of the line as a comment
[       read until ']' as a comment

Examples

Hello World

'Hello, world!\n"

deadfish interpreter

 '>> " #print the shell
_2 +  #set cell 2 to 1
(      #begin main  loop
_0 %4 _4 ~-256 | { _0 =0 } _3 #if cell 0 is equal to 256, set it to 0
> +
> > ^ #read the command to cell 2
& > @i | { _0 + _3 } <  #if the command is i, increment the cell
& > @d | { _0 - _3 } < #if the command is d, decrement the cell
& > @s | { _0 & m _3 } < #if the command is s, square the cell
& > @o | { _0 \ '\n" _3 } < #If the command is the letter o, output cell # 0, followed by a newline
& > ~-10 | { '>> " } < #If the command is a newline, print the shell
+
)

99 bottles of beer

=99 ( \ ' bottles of beer on the wall " \ ' bottles of beer\nTake one down, pass it around, " - \ ' bottles of beer on the wall!\n" )
'No more bottles of beer on the wall, No more bottles of beer, go to the store, buy some more, 99 bottles of beer on the wall!"

Turing Completeness

WTFZOMFG is turing-complete, because brainfuck can be translated to WTFZOMFG. Below is a translator from Brainfuck to WTFZOMFG, written in WTFZOMFG

;START
_0 ^ & > & > & > & > & > & > & > & _0 #input a byte, and copy it 8 times
  #these 8 lines translate a BF instruction to WTFZOMFG
  @+ | { .+ }
> @- | { .- }
> @< | { .< }
> @> | { .> }
> @, | { .^ }
> @. | { .v }
> @[ | { .( }
> @] | { .) }

> + | { :END } #if it is EOF, then goto the end

:START

;END

External resources

Compiler for *nix systems