!@$%^&*()+

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

!@#$%^&*()_+ is another fun stack-based language (in the broader sense) invented by User:Conor O'Brien where character literals have no delimiter with programs that resemble grawlixes (random symbols, typically on the top row of the keyboard, which replace vulgarism). Notably, it is the first language in the language list of Try It Online.

Syntax

!@#$%^&*()_+ operates on a "stack" that allows random access and rotation, which is usually still regarded as a stack in esolangs. Initially, the stack contains a single zero.

The 12 documented instructions are described as follows:

Character Result
! Duplicate.
@ Pop and print as Unicode character.
# Pop and print as integer.
$ Swap.
% Rotate stack 1 right.
^ Increment.
& Indexing. Pop a and push the ath number in the stack (zero-indexed from the bottom)
* Input a character and add it to the number on the stack top.
( If top is 0, go to corresponding ')' (similar to the '[' in brainfuck)
) If top is not 0, go to corresponding '(' (similar to the ']' in brainfuck)
_ Negative.
+ Addition.

Popping from an empty stack gives 0.

Characters that are not instructions, including unprintables, are character literals.

Undocumented instructions

There is one undocumented debugging instruction, ?, which outputs the stack from the bottom to the top 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.

An alternative version that does not use any letters at all:

 ^22+2:+99+78+;<+ ,78+66+!23+' ^+(@)

Again, the leading space, as well as the two spaces in the middle, is mandatory.

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!

This program pushes LO onto the stack and prints them alternately, so the program outputs "LOLOLOL..." indefinitely.

See Also

External resources