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.

K-Cats

From Esolang
Jump to navigation Jump to search

K-Cats is a language thought up by User:NOLATe while he was at the park. He finished typing it up at approximately 21:50 on the 19th of June 2026 in PDT. He came up with the name just now because it is stack-based and K-Cats backwards is stack. Here is the documentation:

Idea: Stackbased language thing
pop: Discard the top of stack
dup: Duplicate the top of stack
flip: Flip the top of stack
bring: (...,a) Takes the ath item from the top of the stack starting at 0 and bring it to the top
	   For example, #3#2#1#0#2 bring would become #3#1#0#2.
if: (c,b,a)->a?b:c
    For example, #2#1#0 if would become #2 and #2#1#1 if would become #1
set: (b,a) There is a storage of items outside of the stack. Sets the item at index b to a.
get: (a) Gets the item at index a.
#: Enter Numeral Mode, pushes the hexadecimal number encoded by the string until a non-numeral is encountered
  The letters A-F must be uppercase, and these sequences can be preceded by a - to indicate negatives 
Stack Bottom to Top
      g f e d c b a
add: (b,a)->b+a
sub: (b,a)->b-a
mul: (b,a)->b*a
div: (b,a)->b/a Do note that all numbers are integers, so this rounds to -infinity.
mod: (b,a)->b%a
divmod: (b,a)->b/a,b%a Remember that the right is the top of the stack
and is bitwise and, or is bitwise or, xor is bitwise xor
gt: (b,a)->b>a
lt: (b,a)->b<a
eq: (b,a)->b=a
not: Negates a boolean number. Acts like #1 xor bool
bool: Returns 0 iff a is 0, else returns 1
nil: Create an empty array
append: ([...],a)->[...,a] Adds an integer to the end of an array
prepend: ([...],a)->[a,...] Adds an integer to the beginning of an array
index: ([...],a)->[...],b Takes the ath item of the array without removing the array. Indexing is 0-based
put: ([...],b,a) Set the bth index of the array to a, allowing negative indexing for the end. This is true for most other array operators.
insert: ([...],b,a) Put a before the bth index of the array, shifting everything after by 1.
cut: ([...],a) If a is positive, removes the first a elements of the array. Otherwise, removes the last -a elements.
len: Gets the length of an array.
extend: Loops an array until it reaches a certain length. If a is less than the length of the array it will act similar to cut.
reverse: Reverses an array


input: Input a number
inputstr: Input a string as an array of ASCII codes
output: Output a number if input is an integer, otherwise output as string.
Now for the fun part! Yay
[]: Enter Quote Mode! All the things in between these brackets will be pushed to the stack as an array of ASCII values. This can be nested, so have fun with it
exec: Pops a string and executes it as a program.
repeat: ([...],a) Like exec, but repeats the program a times.
Instead of recursion to implement this, the interpreter will hold a stack of instructions to be run, and exec pushes to this stack.

A benevolent person (@janmakoso on Discord) made an interpreter in Uiua for K-Cats!