Barrous

From Esolang
Jump to navigation Jump to search

Barrous is an improvement on Modulous inspired by APL made by Abyxlrz. It is a 1D stack based esoteric programming language with variables.

Non-commands

^ can be used in place of a value to refer to the top of the stack.

Variables may be defined by any alphabetic name when they are first called. All variables start at 0

The maximum value is 255 for variables and the stack, if a value goes over that number, it will loop over to 0.

The stack is assumed to have the value 0 when it has no values.

All commands must be separated by bars or newlines. For example: num;5|>2|=|#num|num-1|num<3|<3

If there aren't any commands to run anymore, the program ends.

Monadic arguments only use the argument to the command's right.

Values don't get popped unless specified in explanation.

Commands

Command Name Explanation
y>x Jump forward Monadic: The pointer jumps forward x amount of commands; Dyadic: If y is equal to 0, then the pointer jumps forward x amount of commands, otherwise, do nothing.
y<x Jump backward Monadic: The pointer jumps backward x amount of commands; Dyadic: If y is equal to 0, then the pointer jumps backward x amount of commands, otherwise, do nothing.
v+x Add Dyadic: If v is a variable, then x gets added to v and the result is stored in v. If v is ^, then the top value of the stack becomes the sum of x and v.
v-x Subtract Dyadic: Subtracts x from v and stores the result in v.
y;v Push Dyadic: If v is a variable, then the variable will become the value of x. If v ^ then the value of y will be pushed onto the stack.
:v Pop Monadic: If v is a variable, then it will become undefined. If v is ^ then the top value of the stack is popped.
! Reset Niladic: Resets the pointers position to the start of the program.
= End Niladic: Ends the program.
@x Print character Monadic: Outputs an ASCII character with the value of x.
#x Print value Monadic: Outputs the value of x as a number.
v?x Random Dyadic: If v is a variable, a random integer will be generated from 0 to x and stored into v. If v is ^, a random integer will be generated from 0 to x and is pushed onto the stack.
&v Input character Monadic: If v is a variable, then input is taken from the user as a single ASCII character and the value is stored into v. If v is ^, then input is taken from the user as a single ASCII character and the value is pushed onto the stack.
%v Input number Monadic: If v is a variable, then input is taken from the user as an integer and the value is stored into v. If v is ^, then input is taken from the user as an integer and the value is pushed onto the stack.

Example programs

Count down from 5

num;5|>2|=|#num|num-1|num<3|<3

Truth-machine

%truth|truth>3|#1|<1|#0