Numobin

From Esolang
Jump to navigation Jump to search

Numobin is a esoteric programming language invented by User:Zzo38. The memory is a stack, a boolean value, and a set of variables.

Data Types

Numobin's type system is subjected to a dichotomy into integer numbers and ASCII characters.

Architecture

The program state is defined by three storage components: a stack, a Boolean flag, and a variable registry.

Stack

The primary data repository, the stack provides the means for maintaining integer and character objects. No upper limit applies to this last-in first-out (LIFO) collection's capacity.

Boolean value

A Boolean value, utilized as a flag, permits the helming of the while loop, demarcated by the tokens [ and ]. Two instruction exert their influence on this flag: the unconditional * switch, and the = operation, which toggles the state if and only if the two top stack elements partake of equality.

Variable registry

Both the numeric and character objects may be employed in the agency of variable names, associated with values of the same degree in liberty. The operation { allows for the definition of a variable, whereas } queries and inserts its value into the stack.

Commands

Numobin's instruction set comprehends members for the manipulation of a program's three data repositories — stack, Boolean flag, and variable registry —, as well as an iteration construct, and input/output facilities.

Command Description
# Push the number onto the stack of the number of # that are in the program before this one.
[ Begin loop while the Boolean value is true.
] End loop.
- Pop the two topmost numbers from the stack and push their absolute difference unto the same.
{ Pop the two topmost elements from the stack, using the first one as the variable value and the second as the variable name, and store this association in the variable set.
} Pop the topmost element from the stack, utilize it as a variable name, and push the associated value unto the stack.
~ Swap the top two entries of the stack.
* Toggle the Boolean value.
= Pop the two topmost numbers from the stack and, if they are equal, toggle the Boolean value.
( Pop the top value from the stack and output the ASCII character or number.
) Input an ASCII character or number and push it unto the stack.
? Set the number for starting with # to a random value.
0 = ##-##--
1 = ##-
2 = ###~#=-
3 = ###=#-
4 = ###-#=#-
5 = ##-##=##=#-
6 = ###~#=~-#-
7 = ###=#~-#-

See if there is shorter way of these things (and more numbers), without changing anything after it is done, other than push the number onto stack.

Examples

Cat program

The following cat program repeats infinitely:

*[)(]

Variables

This program prompts the user for an input, stores it in the variable with the numeric name “1”, and prints its value to the standard output:

##-){##-}(

Interpreter

  • Common Lisp implementation of the Numobin programming language.