We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

EverybodyLang

From Esolang
Jump to navigation Jump to search

Add any command you want! (Don't forget updating the implementation!)

Commands

Original commands

Original commands
Command Meaning
H Prints Hello world
Q Prints "Q"
9 Prints 99 bottles of beer
+ Increment current memory cell
- Decrement current memory cell
< Move the pointer left
> Move the pointer right
, Get user input as ASCII/Unicode and store in current memory cell
. Output value of current memory cell as ASCII/Unicode
; Get user input as number and store in current memory cell
: Output value of current memory cell as number

Additional commands

Additional commands
Command Meaning
0 Clear current memory cell
q Prints the code
' Prints the program counter as number
" Prints the program counter as ASCII/Unicode
# Set current memory cell to 1 if it is greater than 0, and 0 otherwise
{ Ignore commands until matching }. Also used as a parameter for some other commands. (I'm too lazy to judge if there is a matching parenthesis or not)
} NOP, only used as a target for {
s Square the current memory cell
/ Divide the current memory cell by 2 (rounded down)
* Set the current memory cell to a random number between 0 and 255
D Jump to previous D
( Jump to corresponding ) if current cell is 0
) NOP, only used as a target for (
[ Jump to corresponding ] if current cell is 0
] Jump back to corresponding [ if current cell is NOT 0
@ Set the current cell to the value in the cell pointed by the current cell's value
={x} set current memory cell to x (a number)
(space) NOP, only serves as padding
v Store value of current memory cell in the register
v{string} Store the string string in the register
V Get user input and store it in the register
^ Output the register as a string
e End the program. All following commands will be ignored.
a Ignore the next command once unless that command is r. If looped back to this command it will not ignore the next command
á Ignore the next commands (the amount is the current cell number) once. If looped back to this command it will not ignore the next commands
r print " are" (with the space) and ignore the next command.
y Set current memory cell to 30
u Print "you"
o Set current memory cell to 999
~ Execute a random valid command other than ~ itself
& Set current memory cell to NaN

Other information

The tape of memory cells is infinite. There is also a single register that can hold strings.
Dividing by 0 or using invalid parameters in a command raises an error.
Memory cells do not wrap and can go above 255, but setting a memory cell to a negative number is undefined behavior.
Optionally, an implementation may inject the coder with estrogen if it detects an error, but this is not required.

Examples

Hello, world! 1

H

Hello, world! 2

={72}.={101}.={108}..={111}.={44}.={32}.={119}.={111}.={114}.={108}.={100}.

Hello, world! 3

v{Hello, world!}^

Quine 1

Q

Quine 2

you are always valid

Quine 3

q

Quine 4/Hello world program 4

Hello, world!

Looping counter

+{D       "}[->+<                         "]>[-<+>]<+D

Implementation

Assume code is the code.

import collections, random

jumps = {}
prefix = None
curly_brackets = []
capital_d = -1
parentheses = []
square_brackets = []
equals, current_equal = {}, None
for i, j in enumerate(code):
	if prefix == "=":
		if j == "}":
			prefix = None
			jumps[current_equal] = i
		if j.isdigit():
			equals[current_equal] *= 10
			equals[current_equal] += int(j)
		continue
	if j == "{":
		curly_brackets.append(i)
	if j == "}":
		jumps[curly_brackets.pop()] = i
	if j == "D":
		jumps[i], capital_d = capital_d, i
	if j == "(":
		parentheses.append(i)
	if j == ")":
		jumps[parentheses.pop()] = i
	if j == "[":
		square_brackets.append(i)
	if j == "]":
		m = square_brackets.pop()
		jumps[i], jumps[m] = m, i
	if j == "=":
		current_equal = i
		equals[current_equal] = 0
		prefix = "="

def ninety_nine_bottles_of_beer():
	print("99 bottles of beer on the wall, 99 bottles of beer.\nTake one down, pass it around,", end = "")
	for i in range(99,0,-1):
		bottle = "bottles"
		if i == 1: bottle = "bottle"
		print("%d %s of beer on the wall.\n%d %s of beer on the wall, %d %s of beer." % ((i,bottle)*3))
		print("Take one down, pass it around, ", end = "")
	print("no bottles of beer on the wall.\nNo bottles of beer on the wall, no bottles of beer.")
	print("Go to store, buy some more, 99 bottles of beer on the wall!")

mem = collections.defaultdict(int)
memc = 0
pc = 0
while pc < len(code):
	cur = code[pc]
	if cur == "H": print("Hello, world!")
	if cur == "Q": print("Q", end="")
	if cur == "9": ninety_nine_bottles_of_beer()
	if cur == "+": mem[memc] += 1
	if cur == "-": mem[memc] -= 1
	if cur == "<": memc -= 1
	if cur == ">": memc += 1
	if cur == ";": mem[memc] = int(input())
	if cur == ":": print(mem[memc], end="")
	if cur == ",": mem[memc] = ord(int(input()))
	if cur == ".": print(chr(mem[memc]), end="")
	if cur == "0": mem[memc] = 0
	if cur == "q": print(code, end="")
	if cur == "'": print(pc, end="")
	if cur == '"': print(chr(pc), end="")
	if cur == "#": mem[memc] = 1 if mem.get(memc, 0) > 0 else 0
	if cur == "{": pc = jumps[pc]
	if cur == "s": mem[memc] **= 2
	if cur == "/": mem[memc] //= 2
	if cur == "*": mem[memc] = random.randint(0, 255)
	if cur == "D": pc = jumps[pc]
	if cur == "(" and mem[memc] == 0: pc = jumps[pc]
	if cur == "[" and mem[memc] == 0: pc = jumps[pc]
	if cur == "]" and mem[memc] != 0: pc = jumps[pc]
	if cur == "@": mem[memc] = mem[mem[memc]]
	if cur == "=": mem[memc], pc = equals[pc], jumps[pc]

	pc += 1