Comp
Jump to navigation
Jump to search
Comp is an esolang by User:Hex96. It is stack based. It is designed for code-golfing.
commands
# print the top value on the stack in ascii. £ print the top value on the stack as a number. ' gets input and pushes the ascii value on to the stack. ; gets input and pushes the number on to the stack. { while the top value on the stack is not 0. } end the loop ! adds one to the top value on to the stack. " subtracts one from the top value on the stack. \ pushes the number after it on to the stack. + gets the top two values on the stack. y being the first one popped, x being the second. x+y. - same thing but -. / same thing but /. * same thing but *. [ if the number before it is the same as the first value popped off the stack, then continue (if x == the number before it). ] end the if. ( same thing as [ but a != not ==. ) end the if not statement @ gets multi input and pushes the ascii values on backwards. < until the top value on the stack is not 0. > end the <. ^ duplicates the top value on the stack. % pops the top value on the stack. _ stops the program. ~ pops the top value on the stack, if it is a 1, push a 0, else, push a 1.
Examples
Hello, World!
\72 # \101 # \108 # \108 # \111 # \44 # \32 # \87 # \111 # \114 # \108 # \100 # \33 #
Truth-Machine
;{^&}&
Calculator
This has the operation last.
;;' \43[%+_] \45[%-_] \42[%*_] \47[%/_]
Implementations
- Someone created a very rudimentary Comp to Keg transpiler. It will take a comp program and turn it into a Keg program that can be executed on sites like Try It Online!. It's stored as a Github Gist
Computational Class
Comp is believed, at least by one person, to be Turing Complete. Why? Because a command map between the Turing Complete esolang Volatile and Comp is possible:
Volatile | Comp |
---|---|
~ |
\1 (Note that the ~ can be replaced with any number, as it is a random number generator)
|
+ |
+
|
- |
-
|
* |
*
|
/ |
/
|
: |
^
|
. |
#
|
(...) |
{...}
|