Kepler

From Esolang
Jump to: navigation, search

Kepler is an esoteric programming language made by Areallycoolusername. It's a deque based, golfing language, made to make golfing a lot easier.

Specifics

Kepler has 7 commands.

Command Function
 ! Pushes a value to the front of the deque
 : Pushes a value to the back of the deque
 ? Pops the value at the front of the deque
 ; Pops the value at the back of the deque
^ Prints the third argument then the second, then the first argument given to this command.
u Prints values given
~ Dumps all the values in the deque along with some of the commands used to fill the deque.

These 7 commands can be used to print anything. More flexibility (as in control flow and variables), are being devised and considered. All the commands have a specific syntax. For the print command, u, you have to put a character value next to it for the command to be valid. e.g:

uq

This prints the character "q". The u command can also be used to print hello world using an abbreviated form. This is demonstrated in the Hello World section of the this page. The push commands, "!" and ":" (push front and push back, respectively), are used to push values onto the deque. e.g:

!J:K

Pushes "J" to the front of the deque, and "K" to the back. The pop commands, "?" and ";" (pop front and pop back, respectively), works similarly, except you don't have to specify a value. e.g:

?;

This pops "J" (front) and "K" (back) from the deque. The switch command, "^", switches the three values given to it in a specific order, and prints them. e.g:

^zyx

This prints "xyz" to the screen. It's function and inclusion in this language is quite arbitrary, but it was added to heighten the power. Finally, the dump command, "~", Dumps all the values in the deque that were originally entered using the ":" and "!" command. e.g:

:h:f:g~

This prints "g:f".

Hello World Programs

uHW
or
Hello,worldu!
or
uHueululuou,uwuouruludu!

Polynomial growth (a bit close to the Infinite loop)

Note: If you repeat the !~ part arbitarily in the Python interpreter, the output will start to grow in the polynomial rate. It will take some time(about 1 second) to output this before this halts:

~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!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~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~

A clean simplification of this program:

~!~

If anyone provides a growth faster than this one, they will get an award! (Probably a thumbs up or something)

This grow slower than the previous one (but it takes advantage of an undiscovered quirk):

!:~!:~!:~!:~!:~!:~!:~!:~!:~!:~!:~!:~!:~!:~!:~!:~

Human-based looping counter

This requires a human to copy the output to the input, but the rest works fine. This one loops 7 times before it stabilizes:

uuuuuuua

Append as many u's as how much the user requires the loop to run.

Simulation of addition (and subtraction, of course)

This requires the user to enter the two constants in unary in this format: repeat !a constant times. After these two constants have been entered, use ~ to present the result of the computation (the result is in unary; count how many 'a''s are in the output, and that will be the result.)

An example computation (6+4):

!a!a!a!a!a!a
!a!a!a!a
~

There are 10 'a''s in the output; therefore, the result is 10.

Subtraction is also easy to do with this structure(this solves 10-6):

!a!a!a!a!a!a!a!a!a!a
??????
~

There are 4 'a''s in the output. So, the result is 4. Note that the user has to enter the minuend in question marks.

Implementation

Here is a C++ interpreter:

#include <iostream>
#include <deque>
#include <cstdlib>
using namespace std;
int main(){
	unsigned char data[10000];
	deque<char> Deque;
	int i = 0; 
	int h = 10000;
	do {
		cin >> data;
		switch(data[i]){
			case '!': Deque.push_front(data[i + 1]);i+=2;
			case ':': Deque.push_back(data[i + 1]);i+=2;
			case '?': Deque.pop_front();
			case ';': Deque.pop_back();
			case '^': cout << data[i + 3];cout << data[i + 2];cout << data[i + 1];i+=4;
			case 'u': if(data[i + 1]=='H'&&data[i + 2]=='W'){cout << "Hello, world!";i += 3;}else{cout << data[i + 1];i += 2;}
			case '\n': i += 1;
			case '~': cout << Deque[i];
			default: cout << data[i];i++;
		}
	}while(i < 10000 && data[i] != NULL);
}

Here is a Python interpreter (this adds the command @, which adds whether the length of the deque is a prime to the front of the deque. This makes Kepler a programming language):

import math
def isprime(number):
    if number > 1:
        if number == 2:
            return 1
        if number % 2 == 0:
            return 0
        for current in range(3, int(math.sqrt(number) + 1), 2):
            if number % current == 0: 
                return 0
        return 1
    return 0
data=""
deque=[]
i=0
h=10000
while i < 10000:
    data=input()
    for i in range(0,len(data)):
        if data[i]=='!':
            deque.insert(0, data[i+1])
        elif data[i]==':':
            deque.append(data[i+1])
        elif data[i]=='?':
            del deque[0]
        elif data[i]==';':
            del deque[-1]
        elif data[i]=='^':
            print(data[i+3]+data[i+2]+data[i+1],end="")
        elif data[i]=='u':
            if data[i+1]=='H' and data[i+2]=='W':
                print("Hello, world!",end="")
            else:
                print(data[i+1],end="")
        elif data[i]=='\n':
            pass
        elif data[i]=='~':
            print(deque,end="")
        elif data[i]=='@':
            deque.insert(0,str(isprime(len(deque))))
        else:
            print(data[i],end="")

Interesting Properties

Kepler has some interesting (and completely accidental), properties that won't be removed (as studying these properties could help make ideas for other languages). It's not Turing complete.

When the "?" command is used with a value, followed by the dump command, "~". It Dumps that value along with the pop command. This is just one of the many quirks found in this language.

However, in the Python interpreter, this will not work. It will throw an error. The Python interpreter is roughly compatible with the C++ interpreter; i.e. you can still find a lot of interesting properties in this interpreter.