!@$%^&*()+

From Esolang
Jump to navigation Jump to search
The title of this article is incorrect because of technical limitations. The correct title is !@#$%^&*()_+.

!@#$%^&*()_+ is another fun esoteric programming language invented by PPCG user Conor O'Brien. It is a stack-based language. Its most highlighted characteristic might be that all characters are considered valid commands in the language (there are no nop commands). The title consists of all of its special commands which are used for manipulating the stack. !@#$%^&*()_+ programs resemble grawlixes (random symbols which replace vulgarism).

Syntax

The syntax in !@#$%^&*()_+ entirely consists of one-letter ASCII characters.

There are 12 special characters. These are usually found on the top of a QWERTY keyboard. The characters are as follows:

N = Top of the stack

M = Number below N

Character Result
! Pushes N to the stack (duplicate N)
@ Outputs the ASCII character associated with N and pops N (Print string)
# Outputs N and pops N (Print integer)
$ Swaps N and M (Swap top two values)
% Puts N to the bottom of the stack (Rotate stack)
^ Adds one to N (Increments N)
& Replaces N with the Nth number in the 0-based stack (Get Nth number)
* Takes one character from STDIN and adds its ASCII value to N, if EOF reached return -1 (Input)
( If N is 0, go to corresponding ')' (similar to the '[' in brainfuck)
) If N is not 0, go to corresponding '(' (similar to the ']' in brainfuck)
_ Multiplies N by -1 (Negate N)
+ Pops N and adds it to M (add N and M)

Any other character, including spaces and newlines, will have their ASCII value pushed on to the stack. Comments can be put at the end of every program (or at least after the last @ or # command)

Note: When the stack is empty, popping from it results in 0. There's a 0 in the stack initially.

Undocumented instructions

There is one undocumented instruction, ?, which outputs the stack along with their index.

Example programs

Spoiler alert: you may want to program these programs by yourself before going in-depth.

Hello world

 ^dlroW ,olleH(@)

Note: the space at the beginning of the program is mandatory.

This program prints the overused coding clichè "Hello, world!".

The space at the starts pushes its ASCII value (32). The ^ increments 32, making it the ASCII value of the exclamation mark (33). The rest of the alphabet push their respective values until it comes into a loop where all of the pushed numbers get printed.

Infinite fibonacci sequence

!#!^! @#(!%+! @#)


The program starts with 1 on top of zero and prints them. After that, the program infinitely puts a copy of N on the bottom of the stack and prints the sum of N and M.

Square numbers

^!(!# @$^^!%+)


This program uses a variable which is incremented twice every iteration and is added to the last square number.

Truth-machine

0_*(!#)#


This code prints a single 0 when the input is zero, otherwise, it repeatedly prints the input.

99 bottles of beer

c(!#!!_+
,llaw eht no reeb fo selttob (@)$!#$
,dnuora ti ssap ,nwod eno ekaT
.reeb fo selttob (@)$_^_!#$
.llaw eht no reeb fo selttob (@)!_++)


This program prints the entire nursery rhyme '99 bottles of beer' (with an extra space/newline in the end).

Also, the grammatical mistake of "1 bottles of beer" is present.

Parity

*(_^_$_^$)$(O@d@d@  _+)+_^(E@v@e@n@  _+)

This program reads a character and determines whether its ASCII value is even or odd.

LOLOL

LO($!@)

It is now your time to figure out what this does!

Ctrl-A to see the answer: It pushes LO onto the stack and prints them alternately, so the program outputs "LOLOLOL..." indefinitely.

See Also

External resources