!@$%^&*()+/Algorithms

From Esolang
Jump to navigation Jump to search

This page provides common code snippets for easy !@#$%^&*()_+ programming, inspired by Brainfuck algorithms.

Push zero

xx_+

You may replace 'x' represents any character other than the special commands.

Drop

!_++

Discards the current top member of the stack.

Comment

xx_+(Your comment goes here)+

The text inside the brackets will be ignored by the compiler.

Decrement

_^_

Decrements the top member of the stack

Division

xx_+$(_^^_$^$)+

Divides the top of the stack by the number of ^'s between the underscores, in this case, the code divides by 2.

Warning: If the dividend is not divisible by the divisor, the code will get into an infinite loop.

Store Input

*^(  _+*^)%(_^_%)+

Works if EOF is -1.

Stores the entirety of the input as individual ASCII values onto the stack

Get Integer

*^(%  _+*^)%(0_+%)%  _+^$($_^_$_^_$+!!!!!!!!!+++++++++^$)+_^_  _+$(_^^^^^^^^^^_$^$)+

This code gets the positive Integer from STDIN and pushes it to the stack. Only works when STDIN has only a number and nothing else.

Note: A program can get slower if the input number is too big.

Parity

  _+(_^_$_^$)$

Turns the top of the stack to 0 if even, and 1 if odd.