0% found this document useful (0 votes)
20 views1 page

MiniScript Language Overview and Guide

MiniScript is a high-level, object-oriented programming language with a clean syntax that emphasizes readability. It supports various data types including numbers, strings, lists, and maps, and allows for the creation of functions and classes. The document provides a quick reference for syntax, control flow, and intrinsic functions available in MiniScript.

Uploaded by

mkirisame274
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

MiniScript Language Overview and Guide

MiniScript is a high-level, object-oriented programming language with a clean syntax that emphasizes readability. It supports various data types including numbers, strings, lists, and maps, and allows for the creation of functions and classes. The document provides a quick reference for syntax, control flow, and intrinsic functions available in MiniScript.

Uploaded by

mkirisame274
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Welcome to MiniScript!

Data Types Functions


MiniScript is a high-level object-oriented Create a function with function(),
Numbers
language that is easy to read and write. including parameters with optional
All numbers are stored in full-precision default values. Assign the result to a
Clean Syntax format. Numbers also represent true (1) variable. Invoke by using that variable.
and false (0). Operators: Use @ to reference a function without
Put one statement per line, with no
semicolons, except to join multiple +, -, *, / standard math invoking.
% mod (remainder) triple = function(n=1)
statements on one line.
^ power return n*3
Code blocks are delimited by keywords and, or, not logical operators end function
(see below). Indentation doesn't matter ==, !=, >, >=, <, <= comparison print triple // 3
(except for readability). print triple(5) // 15
Strings f = @triple
Comments begin with //.
Text is stored in strings of Unicode print f(5) // also 15
Don't use empty parentheses on
function calls, or around conditions in if characters. Write strings by
or while blocks. surrounding them with quotes. If you Classes & Objects
need to include a quotation mark in the A class or object is a map with a special
All variables are local by default. string, type it twice. __isa entry that points to the parent.
MiniScript is case-sensitive.
print "OK, ""Bob""." This is set automatically when you use
Control Flow Operators: the new operator.
+ string concatenation Shape = {"sides":0}
if, else if, else, end if - string subtraction (chop) Square = new Shape
*, / replication, division [Link] = 4
Use if blocks to do different things
==, !=, >, >=, <, <= comparison x = new Square
depending on some condition. Include [Link] // 4
[i] get character i
zero or more else if blocks and one [i:j] get slice from i up to j Functions invoked via dot syntax get a
optional else block.
self variable that refers to the object
if 2+2 == 4 then Lists they were invoked on.
print "math works!"
Write a list in square brackets. Iterate [Link] = function()
else if pi > 3 then
over the list with for, or pull out return 180*([Link]-2)
print "pi is tasty"
else if "a" < "b" then individual items with a 0-based index in end function
print "I can sort" square brackets. A negative index [Link] // 360
else counts from the end. Get a slice
print "last chance" (subset) of a list with two indices, Intrinsic Functions
end if separated by a colon.
x = [2, 4, 6, 8]
Numeric
while, end while x[0] // 2 abs(x) acos(x) asin(x)
Use a while block to loop as long as a x[-1] // 8 atan(y,x) ceil(x) char(i)
condition is true. x[1:3] // [4, 6] cos(r) floor(x) log(x,b)
x[2]=5 // x now [2,4,5,8] round(x,d) rnd rnd(seed)
s = "Spam"
pi sign(x) sin(r)
while [Link] < 50 Operators:
sqrt(x) str(x) tan(r)
s = s + ", spam" + list concatenation
end while *, / replication, division String
print s + " and spam!" [i] get/set element i
[i:j] get slice from i up to j .indexOf(s) .insert(i,s)
for, end for .len .val .code
Maps .remove(s) .lower .upper
A for loop can loop over any list, .replace(a,b) .split(d)
including ones easily created with the A map is a set of values associated with
range function. unique keys. Create a map with curly List/Map
for i in range(10, 1) braces; get or set a single value with .hasIndex(i) .indexOf(x)
print i + "..." square brackets. Keys and values may .insert(i,v) .join(s)
end for be any type. .push(x) .pop .pull
print "Liftoff!" m = {1:"one", 2:"two"} .indexes .values
m[1] // "one" .len .sum .sort
break & continue .shuffle .remove(i)
m[2] = "dos"
The break statement jumps out of a range(from,to,step)
Operators:
while or for loop. The continue
statement jumps to the top of the loop,
+ map concatenation Other
[k] get/set value with key k
skipping the rest of the current iteration. print(s) time wait(sec)
.ident get/set value by identifier
locals outer globals
yield

MiniScript QuickRef version 1.5

You might also like