Here's Some Predefined Stuff. Now Go Invent Everything Else

From Esolang
Jump to navigation Jump to search

Here's Some Predefined Stuff. Now Go Invent Everything Else, which will be called HSPSNGIEE from this point on, is an esolang where all you are given is the bare minumum of a programming language, which is types for numbers, booleans, strings, arrays, and functions, as well as premade functions and variables. Arrays are zero-indexed and all inputs of a function are required. You are also given basic arithmetic and string concatenation and mod as well. You can also overload functions as long as their inputs are of different types or there are more or less inputs.

Predefined Functions

Predefined Functions
Function Meaning Example Notes
! Returns the length of a number, string, or array. Overloads based on input v (! 2763) //returns 4
c Returns an array of the characters in the string "h","i"|
~ Returns the types in the array as their default values 1,"foo","bar"|) //returns |0,""|
@ Returns the element in the array at the corresponding index 1,2,3|;2) //returns 2
# Returns a number corresponding to the input v (# y) //returns 1 Will give an error if you put a non-numeric string in the input
& Returns a string corresponding to the input v (& x) //returns "false"
? Returns a boolean corresponding to the input v (? 1) //returns true
v Prints anything v ("Hello, World!") //returns "Hello, World!"
^ Asks for any type as input v (^) //cat If you put anything in the input, it only accepts input that is the type of the value given as input
a Returns an array containing the ASCII values of each character in the string, or returns the character corresponding to the character with the ASCII value. Overloads based on value v (a 64) //returns "A"
n NOOP n //literally nothing

Syntax

(Stuff inbetween parenthesis is optional)

Syntax
Syntax Meaning
name = T: value Creates a variable of type T named name that has a value of value. Is always mutable. If using an array, you can set it's length by using Array name: length = value, and you can set the types allowed in the array by using Array[type1, type2, ...] name = value. Will return an error if value does not match the type.
name: value Modifies a variable. Will return an error if name is not defined yet, or value does not match the type of name.
function (input1 = T;input2 = T2;...): Creates a function called function (with an input called input1 of type T and an input called input2 of type T2 and...)
function Runs a function called function. Will return an error if function() isn't defined yet. If using functions as arguments, surround functions with parenthesis.
element1;element2;... | Creates an array. Elements are formatted like function arguments.
> Returns something. Must be put in a function and is treated like a function
array[n] Gets the nth item of an array.
t T (contain1 = T;contain2 = T2;...) Makes a type called T (that must contain something of type T, something of type T2, ...)

Examples

Hello, World!

v "Hello, World!"

Truth-machine

if condition=B;runIfTrue=F;runIfFalse=F:
  @ |(runIfTrue);(runIfFalse)|;(# condition)
forever runForever=F:
  if y;(runForever);n
if (* (^ 1));(v 1);(forever (v 0))

Quine

code = S: " v "code = S: " + A 34 + code + A 34 + A 10 + code"
v "code = S: " + A 34 + code + A 34 + A 10 + code

Better-machine

if condition = B;runIfTrue = F;runIfFalse = F:
  @ |(runIfTrue);(runIfFalse)|;(# condition)
not input = B:
  if input;(> x);(> v)
equal input1 = N;input2 = N:
  > (not (* input1-input2))
repeat howManyTimes=N, runManyTimes=F):
  if (* (howManyTimes));(doItAgainLol:
    runManyTimes
    repeat howManyTimes-1;(runManyTimes) 
  );?
forever runForever=F:
  if y;(runForever);n
input = A: |(^ 1);(^ 1)|
if (equal (@ input;0);(@ input;1));(repeat (@ input;0)+(@ input;1);(v 1));(forever (v 1))