CreativeScript v2

From Esolang
Jump to navigation Jump to search

An update to CreativeScript by Unname4798.

Commands

say! a print string a
set! a b set variable a to b
add! a b c add a and b
sub! a b c subtract a and b
mul! a b c multiply a and b
div! a b c divide a and b
mod! a b c modulo a and b
out! a print variable a
in! a set variable a to user input

Examples

Hello world

say! Hello world!

XKCD Random Number

say! 4

A+B Problem

in! a
in! b
add! a b c
out! c

Conjecture

This language used to be marked as "Unusable for programming" but is rather one of the most usable total languages. It not only has a (therorically) infinite amount of variables rather than using a stack but it also has mathematical operations. This is the most powerful a total programming language can get (other than allowing for loops, and also we are ignoring recursive functions because that is undecidable). Now if we assume the divide function is floor divide we can get the == equal function and the != does not equal function from negation.

Equals function in creative script (assuming floordiv):

in! a
in! b
set! one 1
sub! a b diff
mul! diff diff sq
add! sq one sq_plus1
add! sq sq_plus1 temp
sub! temp one temp_minus1
div! temp_minus1 sq_plus1 neq
sub! one neq eq
out! eq

Now that we are gifted the equals function we can do things such as conditionals like so (written in python to avoid massive code):

H = 72  # H
I = 105 # i

B = 66  # B
Y = 121 # y
E = 101 # e

IN = int(input(">"))
ONEOUT = ((IN==1)*H)+((IN!=1)*B)
TWOOUT = ((IN==1)*I)+((IN!=1)*Y)
THREEOUT = ((IN==1)*0)+((IN!=1)*E)
print(chr(ONEOUT), end="")
print(chr(TWOOUT), end="")
print(chr(THREEOUT), end="")

This code prints Hi if the input is one and Bye if the input is anything but one, this exact same tactic really covers a massive field of stuff in terms of conditionals, maybe everything. This also becomes of a neat trick when you print ascii 0, it does not do anything at all. Now normal CreativeScript v2 would just print numbers but you can convert those numbers it prints into ascii.

You also don't really need for loops, you can unravel them to what you think they will maximally reach. While loops also go for the same thing, you might need some funny tricks to pull all the code together but it works pretty nicely. A more developed form of this programming is shown in Windmill. A program in windmill can eventually be broken down into a form like this, but replacing the while loop part of the programming language into multiple copy and pastes; unfurling the loop. Now this doesn't mean this language is Turing complete because it is not, it is total it can never be Turing complete, but it is the most powerful a Total language can become.