C@

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

C@ (cat) is an esolang speedran by User:BoundedBeans. Let’s see how long it takes to write this exclusive specification.

All characters of input are pushed onto the stack at the start of the program.

Commands

: duplicate
/ swap
$ discard
. print
Anything else: push to the stack.

Examples

5-character text reverser

.....

One character cat/Quine

.

This is normally a one character cat taking the last character, but if the input is ., this program is a quine. In fact, any program consisting of only dots is a quine if given only dots as the last (program length) characters of input.

Two character cat

/..

Bigger cats

C@ cannot create any larger cats than two characters, though it can make text reversers, and it can make quines of any size.

Text scrambler

Will scramble the last 10 characters of text

/../../../../../../../../../..

Insert "CAT" into reversed text after every character

Works with 10 characters.

C.A.T..C.A.T..C.A.T..C.A.T..C.A.T..C.A.T..C.A.T..C.A.T..C.A.T..C.A.T..

Hello world

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

Alternatively:

!dlrow olleH............

Use

This may be a somewhat useful language for text-processing algorithms that:

  • do not have any sort of randomness or conditionals
  • do not have loops other than defined for loops
  • process text in reverse and not in any other order
  • process the last characters of input rather than the first
  • process a defined number of characters
  • have exactly one possible output for each possible input
  • do not insert colons, forward slashes, dollar signs or periods anywhere
  • only ever work with two characters at a time

Implementation

Implementation in Python (which I'm just learning, so forgive me if it's bad):

program = "....." #<- insert program here

stack = input("")
output = ""
 
for i in program:
    if i == ":":
        stack += stack[-1]
    elif i == "/":
        stack = stack[:-2] + stack[-1] + stack[-2]
    elif i == "$":
        stack = stack[:-1]
    elif i == ".":
        output += stack[-1]
        stack = stack[:-1]
    else:
        stack += i
 
print(output) 

#input command is here so that you can see the output when directly running the file through File Explorer
#as soon as you press enter the program will end
input("")