+-

From Esolang
Jump to navigation Jump to search

+-, or ID, is a language created by User:Anonymous in 2017. +-=, +-=*/!&#, and +-=*/@%#()< are additions to the language that append extra features to the previous.

+-

Commands

+- consists of a single accumulator, along with 2 single-character commands to change it. Using other characters besides these will result in the string Error! being alerted to console or an alert box. Whether the alert is done only once or repeated by character is not stated. This does not stop the program from continuing its execution.

Command Action
+ Increments the accumulator.
- Decrements the accumulator.

Examples

Sets the accumulator to 1:

+

to 5:

+++++ 

to 64:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Interpreters

Java

public static void interpret(String p){
        int a = 0;
        boolean b = true;
        for(int i = 0; i < p.length(); ++i){
            switch(p.charAt(i)){
                case '+': ++a; break;
                case '-': --a; break;
                default: if(b){ b = !b; System.err.println("Error!"); }
            }
        }
    }
}

JavaScript

const interpret = p => {
    var a = 0;
    if(p.match(/[^+-]/)){ console.error('Error!') }
    for(const c of p){
        switch(c){
            case '+': a++; break;
            case '-': a--; break;
            default: console.error('Error!');
        }
    }
}

Python 3

def id():
    acc = 0
    while True:
        prg = input('\n+-> ')
        for cmd in prg:
            if cmd == '+': acc += 1
            elif cmd == '-': acc -= 1
            else: print('Error!')

C

#include <stdio.h>

int main() {
  int ch, ax = 0;
  while(ch = getchar()) {
     ax += (ch == '+') - (ch == '-');
  }
  return 0;
}

Fist

:code
?
+>+
->-
#>end
:+
.1
>code
:-
.0
>code
:end

Counter value is numbers of 1 outputed - numbers of 0 outputed to the screen

+-=

+-=, or IDPL, is the same as +-, except the = operator is added for output.

Commands

Command Action
+ Increments the accumulator.
- Decrements the accumulator.
= Prints the accumulator and a newline.

Examples

Prints 42:

++++++++++++++++++++++++++++++++++++++++++=

Counts to 10 (separated by newlines):

+=+=+=+=+=+=+=+=+=+=

Prints the ASCII values for Hello World (word wrapped):

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=+++++++
++++++++++++++++++++++=+++++++==+++=--------------------------------------------
-----------------------=------------=+++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++=--------=+++=------=--------=------
-------------------------------------------------------------=------------------
-----=

Interpreters

Java

public static void interpret(String p){
    int a = 0;
    for(int i = 0; i < p.length(); ++i){
        switch(p.charAt(i)){
            case '+': ++a; break;
            case '-': --a; break;
            case '=': System.out.println(a); break;
            default: System.err.println("Error!");
        }
    }
}

JavaScript

const interpret = p => {
    var a = 0, t = ;
    for(const c of p){
        switch(c){
            case '+': a++; break;
            case '-': a--; break;
            case '=': t += '\n' + a; break;
            default: console.error('Error!');
        }
    }
    console.log(t.substring(1));
}

A separate version is shown below for converting text into +-= code.

const terpretni = t => {
    t = t.split();
    var p = , a = 0;
    while(t.length){
        
    }
    console.log(p);
}


Python 3

def idpl():
    acc = 0
    while True:
        prg = input('\n+-=> ')
        for cmd in prg:
            if cmd == '+': acc += 1
            elif cmd == '-': acc -= 1
            elif cmd == '=': print(acc)
            else: print('Error!'); break

REALScript++

print +-=Interpreter 
print YourCode: 
new code 
new acc 
new t 
new cmd 
input #code 
join code ; 
letter t #acc 
!label run 
letter cmd #code 
if #cmd ; end 
if #cmd + inc 
if #cmd - dec 
if #cmd = out 
goto run 
!label inc 
join acc * 
goto run 
!label dec 
letter t #acc 
goto run 
!label out 
print #acc 
goto run 
!label end 
print CodeExecuted. 

Usability

+-= may be usable for very specific Kolmogorov-complexity challenges, if the task is to print numbers on each line.

+-=*/!&#

+-=*/!&# is a language that expands +- more with 6 more commands, adding the feature to print as an ASCII character among others. The alert feature from before is removed, and = does not insert a newline.

Commands

Command Function
+ Increments the accumulator.
- Decrements the accumulator.
= Prints the accumulator.
* Prints the accumulator as an ASCII character.
/ Sets the accumulator to 0.
! Increments the accumulator by 10.
& Decrements the accumulator by 10.
# Prints a newline.

Examples

FizzBuzz

!!!!!-*#+*#!!*!!!+++++*!!---**#&&&&&&&*#!++++*!!!!!+*+++++**#&&&&&--*!!!+++++*!!
---**#&&&&&&&+++*#+*#!++++*!!!+++++*!!---**#&&&&&&++++*!!!!!+*+++++**#/!!!!!-**#
!!+*!!!+++++*!!---**#/!!!!!-*++*#--*+++*#!!--*!!!+++++*!!---**&&&&&&++++*!!!!!+*
+++++**#/!!!!!-*+++++*#-----*!----*#!+++++*!!!+++++*!!---**#/!!!!!-*!--*#!-*!!!!
!+*+++++**#&&&&&--*!!!+++++*!!---**#/!!!!!**#*+*#!!-*!!!+++++*!!---**#&&&&&&++++
*!!!!!+*+++++**#/!!!!!*++++*#!!----*!!!+++++*!!---**#/!!!!!*!----*#&++++*!---*#!
+++*!!!+++++*!!---**&&&&&&++++*!!!!!+*+++++**#/!!!!!+*--*#++*-*#!!*!!!+++++*!!--
-**#/!!!!!+*+*#!++++*!!!!!+*+++++**#&&&&&--*!!!+++++*!!---**#/!!!!!+*++++*#----*
+++++*#!++++*!!!+++++*!!---**#&&&&&&++++*!!!!!+*+++++**#&&&&&&&*---*#!!+*!!!++++
+*!!---**#&&&&&&&*-*#+**#!!--*!!!+++++*!!---**&&&&&&++++*!!!!!+*+++++**#&&&&&&&*
++*#--*+++*#!+++++*!!!+++++*!!---**#&&&&&&&*+++++*#!-*!!!!!+*+++++**#&&&&&--*!!!
+++++*!!---**#&&&&&&&+*---*#+++*--*#!!-*!!!+++++*!!---**#&&&&&&++++*!!!!!+*+++++
**#&&&&&&&+*+*#!!----*!!!+++++*!!---**#&&&&&&&+*+++*#---*++++*#!+++*!!!+++++*!!-
--**&&&&&&++++*!!!!!+*+++++**#&&&&&&&++*-----*#+++++*----*#!!*!!!+++++*!!---**#&
&&&&&&++*--*#!++++*!!!!!+*+++++**#&&&&&--*!!!+++++*!!---**#&&&&&&&++*+*#-*++*#!+
+++*!!!+++++*!!---**#&&&&&&++++*!!!!!+*+++++**#&&&&&&&+++*&++++*#!!+*!!!+++++*!!
---**#&&&&&&&+++*----*#++++*---*#!!--*!!!+++++*!!---**&&&&&&++++*!!!!!+*+++++**#
&&&&&&&+++*-*#+**#!+++++*!!!+++++*!!---**#&&&&&&&+++*++*#!-*!!!!!+*+++++**#&&&&&
--*!!!+++++*!!---**#&&&&&&&++++*&++++*#!----*-----*#!!-*!!!+++++*!!---**#&&&&&&+
+++*!!!!!+*+++++**#&&&&&&&++++*--*#!!----*!!!+++++*!!---**#&&&&&&&++++**#*+*#!++
+*!!!+++++*!!---**&&&&&&++++*!!!!!+*+++++**#/!!!!!!---*&++*#!--*&+++*#!!*!!!++++
+*!!---**#/!!!!!!---*-----*#!++++*!!!!!+*+++++**#&&&&&--*!!!+++++*!!---**#/!!!!!
!---*--*#++*-*#!++++*!!!+++++*!!---**#&&&&&&++++*!!!!!+*+++++**

Hello World

!!!!!!!++*!!!-*!---**+++*/!!!++*!!!!!+++++*!!++++*+++*&++++*&++*/!!!+++*

Interpreters

Java

public static void interpret(String p){
    int a = 0;
    for(int i = 0; i < code.length(); ++i){
        switch(p.charAt(i)){
            case '+': ++a; break;
            case '-': --a; break;
            case '=': System.out.print(a); break;
            case '*': System.out.print((char)a); break;
            case '/': a = 0; break;
            case '!': a += 10; break;
            case '&': a -= 10; break;
            case '#': System.out.println(); break;
        }
    }
}

JavaScript

function interpret(p){
    var a = 0, o = ;
    for(const c of p){
        switch(c){
            case '+': a++; break;
            case '-': a--; break;
            case '=': o += a; break;
            case '*': o += String.fromCharCode(a); break;
            case '/': a = 0; break;
            case '!': a += 10; break;
            case '&': a -= 10; break;
            case '#': o += '\n'; break;
        }
    }
    console.log(o);
}

ProcessingJS

var interpreter = function(code){
    var o = "";
    var a = 0;
    for(var i = 0; i < code.length; i++){
        switch(code.charAt(i)){
            case "+": acc++; break;
            case "-": acc--; break;
            case "=": console.log(acc); break;
            case "*": console.log(String.fromCharCode(acc)); break;
            case "/": acc = 0; break;
            case "!": acc += 10; break;
            case "&": acc -= 10; break;
            case "#": console.log("\n");
        }
    }
    println(o);
};

Python 3

def pmeaseap():
    acc = 0
    while True:
        prg = input('\n+-=*/!&#> ')
        for cmd in prg:
            if cmd == '+': acc += 1
            elif cmd == '-': acc -= 1
            elif cmd == '=': print(acc, end="")
            elif cmd == '*': print(chr(acc), end="")
            elif cmd == '/': acc = 0
            elif cmd == '!': acc += 10
            elif cmd == '&': acc -= 10
            elif cmd == '#': print()

+-=*/@%#()<

+-=*/@%#()< is a language that expands +-=*/!&# with a few more commands. This makes it a lot more usable.

Commands

! and & have been removed for redundancy and replaced with the () operator.

Command Action
+ Increments the accumulator.
- Decrements the accumulator.
= Prints the accumulator's value.
* Prints the accumulator as an ASCII character.
@ Inputs the next integer to the accumulator.
% Inputs the next character in ASCII to the accumulator.
/ Sets the accumulator to 0.
# Prints a newline.
(n) Repeats the previous command n times. () will instead use the accumulator as the amount of times to repeat.
< Moves the pointer one command back. Both (n) and () do not count as a command and are considered part of the repeated operator before it. <(x) can go back multiple commands.

Examples

Hello World

+(72)*+(29)*+(7)**+++*-(67)*-(12)*+(87)*-(8)*+++*-(6)*-(8)*-(67)*-(23)*

Cat program

%*<(2)

Truth machine

@ takes in an integer input (assumed to only be 0 or 1) and sets it to the accumulator. = prints 0 or 1 once. If the accumulator is 0, <() is skipped and the program ends. Else, it skips back one command to = and repeatedly prints 1.

@=<()

Interpreters

Python 3

The Python 3 Interpreter (created by Seth Peace) is available here.