C@++

From Esolang
Jump to navigation Jump to search

C@++ is an extension of C@ by User:BoundedBeans, made for simple text algorithms.

Commands

:  duplicate
/  swap
$  discard
.  print
#  rot
%  over
&  tuck
]  Makes the next command operate on the stack as groups of two.
   This can be stacked, for example, ]: is like forth's 2DUP, while ]]:
   would be like a 3DUP
@  Pop digits to make a base-10 number n until the top of the stack is not a digit (don't pop the non-digit),
   roll the top element n places down
~c Push the character c to the stack, ignoring its meaning
[  push the stack depth to the stack as decimal digits
+  A command disambiguator
+| Reserved for extensions, can be another disambiguator or just take stuff from the stack to determine what to do
+@ Like @, but pops an additional character before rolling, so that a digit can be rolled
+[ Push (the stack depth) - 1 to the stack as decimal digits (to work with +@ for rolling the entire stack)
+A Pop two series of digits a and b, each terminated by an underscore, pushes a number of a similar format representing a + b
+B like +A but pushes a - b
+C like +A but pushes a * b
+D like +A but pushes a / b
+E like +A but pushes a modulo b
+_ Pops a series of digits x, terminated by an underscore. Breaks out of the x innermost loops currently executing.
Anything else: push to the stack.

Loops are also supported to run as long as the top of the stack is not a certain character. This syntax is XCLX, where L is the loop contents, C is the character to check against, and X's are the loop brackets. Loop brackets with inside depth of n are encoded as Unicode character #(8239 + n), and cannot be greater than #8286, so the loop brackets, from outermost to innermost, are:

‰ ‱ ′ ″ ‴ ‵ ‶ ‷ ‸ ‹ › ※ ‼ ‽ ‾ ‿ ⁀ ⁁ ⁂ ⁃ ⁄ ⁅ ⁆ ⁇ ⁈ ⁉ ⁊ ⁋ ⁌ ⁍ ⁎ ⁏ ⁐ ⁑ ⁒ ⁓ ⁔ ⁕ ⁖ ⁗ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞

Prefixing the loop brackets with +. inverts the condition so they run as long as the top of the stack is a certain character.

Examples

Hello, world!

H.e.l:..o.,. .w.o.r.l.d.!.

Technically doesn't save any bytes over the following but is cooler for showing off duplication.

H.e.l.l.o.,. .w.o.r.l.d.!.

Truth-machine

Since C@++ only takes in a string of input, it can't be interactive, therefore the input string should be 1 or 0.

+.‰1:.+.‰+.‰0._1+_+.‰