@!+-()

From Esolang
Jump to navigation Jump to search

@!+-() is an esolang by User:ChuckEsoteric08. Language was named after 6 main commands in the language

Specification

Uses Queue and Accumulator as memory.

@ - enqueue accumulator
! - dequeue element and store it in accumulator
+ - increment accumulator
- - decrement accumulator
( - if accumulator is zero go past matching )
) - go back to matching (
, - output accumulator as ASCII character
. - store ASCII value of the next byte of user input in accumulator

Examples

Cat

.(,.)

Print "HI"

++++++++++@(-)@!(-@!+++++++@!)!++,+,

Implementing conditional statements

You could make "if" statement, which would run if accumulator is nonzero (with a caveat that it would set accumulator to 0 after it ran).

If statement

Ask for input and if it is nonzero enqueue it:

.(@(-))

If-else statement

Ask for input and if it is nonzero output it, else output "H":

.@(-)+@!(,@!-@(-))!@!(!(-)++++++++++@(-)@!(-@!+++++++@!)!++,(-))

Truth machine

.------------------------------------------------(++++++++++++++++++++++++++++++++++++++++++++++++,------------------------------------------------)++++++++++++++++++++++++++++++++++++++++++++++++,

Interpreter

Javascript

let[a,b,c,j]=[prompt(),[],0,0];for(let i=0;i<a.length;++i){if(a[i]=='@'){b.push(c)}if(a[i]=='!'){c=b.shift()}if(a[i]=='+'){c=(c+1)%256}if(a[i]=='-'){c=(c-1)%256}if(a[i]=='('){if(c==0){j=1;while(j){++i;if(a[i]=='('){++j}if(a[i]==')'){--j}}}}if(a[i]==')'){if(c>0){j=1;while(j){--i;if(a[i]==')'){++j}if(a[i]=='('){--j}}}}if(a[i]==','){console.log(String.fromCharCode(c))}if(a[i]=='.'){c=prompt().charCodeAt(0)}}

See also

External resources