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.
3chr
Jump to navigation
Jump to search
3chr is an esolang by User:Cordership.
Commands
| Command | Definition |
|---|---|
| pot | Pop top of stack, output as character without a trailing newline. |
| pit | Pop top of stack, output as integer with a trailing space. |
| dis | Pop top of stack and discard. |
| psh thing | Push integer, character, or string. |
| int | Push integer input into the stack. |
| icr | Push character input into the stack. |
| isr | Push string input into the stack. |
| add | Pop two values a and b, push the result of a + b. |
| sub | Pop two values a and b, push the result of b - a. |
| mul | Pop two values a and b, push the result of a * b. |
| div | Pop two values a and b, push the result of b / a, rounded down. |
| mod | Pop two values a and b, push the result of b % a. |
| exp | Pop two values a and b, push the result of b ** a. |
| len | Refers to the stack's current length. |
| rev | Reverse the stack. |
| lbl [insert label name here] | Label. |
| jmp [insert label name here] | Jump to a label. |
| sin, cos, tan, cot, sec, csc | Self-explanatory. |
| fin: | Pop topmost stack element as n, then loop n times. |
| pbx | Pop top of stack and push it into the ctrl stack. |
| obx | Pop top of ctrl stack and push it into the stack. |
| # | Starts a comment. |
| dis | Pop top of stack and discard. |
| pop var_name | Pop as a variable. |
Control flow
If-else:
cif condition: # var <op> int / len <op> int
code
eif condition:
code
…
els:
code
Looping:
whl condition:
code
fin:
code
Programs
Hello, World!
psh "!dlroW ,olleH"
whl len != 0:
pot
Cat program
whl 1:
icr
pot
Alternative:
isr
rev
whl len != 0:
pot
Reverse cat
isr
whl len != 0:
pot
A+B problem
int int add pit
User:PrySigneToFry/烂下攫用乴 constant
psh ".0"
dup
whl len != 0:
pot
psh 1
whl 1:
fin:
psh 0
pit
pop a
psh a
psh a
pit
psh 1
add
Disan count
int
psh 0
pop x
pop y
psh x
psh y
pop a
psh a
psh a
fin:
rev
pop a
psh a
psh a
psh 2
mod
pop t
cif t == 0:
pop a
psh a
psh a
pit
rev
pbx
pbx
psh "neve si "
whl len != 0:
pot
psh 10
pot
obx
obx
psh 1
add
rev
psh 1
sub
99 bottles of beer
psh 99
pop a
psh a
psh a
fin:
pop a
psh a
psh a
pit
psh "llaw eht no reeb fo selttob "
whl len != 1:
pot
psh 10
pot
pop a
psh a
psh a
pit
psh "reeb fo selttob "
whl len != 1:
pot
psh 10
pot
psh "dnuora ti ssap ,nwod eno ekaT"
whl len != 1:
pot
psh 10
pot
psh 1
sub
pop a
psh a
psh a
pit
psh "llaw eht no reeb fo selttob "
whl len != 1:
pot
psh 10
pot
psh 10
pot
dis
psh "llaw eht no reeb fo selttob 0"
whl len != 0:
pot
psh "reeb fo selttob 0"
whl len != 0:
pot
psh "erom emos yub ,erots eht ot oG"
whl len != 0:
pot
psh "llaw eht no reeb fo selttob 99"
whl len != 0:
pot