MyScript is an esolang created by User:PythonshellDebugwindow.
Functions in MyScript are different in that they don't need brackets, e.g.
add(a, b) ->
add a b. This means that functions can't have arbitrary amounts of arguments (but an array could easily be used instead). So what in many languages would be
B(A(D()), C(D(), B(E(), D()), E())))
if instruction A takes 1 argument, B takes 2, C takes 3, and D and E both take none, then the equivalent MyScript code would be
B A D C D B E D E
To create one:
var fname is func *args ...
Function to print Hello World:
var printHelloWorld is func say "Hello, World!"
Function to add 2 numbers:
var add2Numbers is func firstNum secondNum return add firstNum secondNum
Function to sum an array (this one’s a bit more advanced):
var sumArray is func a var res is 0 var i is 0 while less i arrlen a, res is add res itemat a i i is add i 1 return res
To create one:
var vname is val
To modify one once created:
vname is val
To access one once created:
To add A and B:
add A B
To subtract them:
subtract A B
multiply A B
divide A B
In MyScript, the keywords
else keywords are used with the
check keyword to form a switch statement:
check val? if value1, ... if value2, ... ... if valueN, ... else, ...
if is like case, and
else is like default. You can have any amount of ifs, and 0 or 1 elses.
Executes code while condition converted to a boolean evaluates to yes (true):
while condition, code
Loops until the user says "stop":
say "Say 'stop' to stop" while not equals ask "stop", say "Say 'stop' to stop" say "You said 'stop'"
|String||"abc\nThis is a \"test\""|
|Array||[123, 4.5, "s", no, 0, 3.14159]|
Strings only use double quotes (valid escape sequences are \0, \n, \\, \t, \f, and \"), and Boolean true is represented by
yes and false by
say "Hello, World!"
while yes, say ask
check ask? if "1", while yes, say "1" else, say "0"
var MyClass is func prop return [prop] var MyClass_myMethod is func obj say concat "obj.prop: " itemat obj 0 var MyClass_getProp is func obj return itemat obj 0 var myObject is MyClass "Hello!" MyClass_myMethod myObject
This should print