Install this vscode extension for syntax highlight
- Variables
lit name be "Roshan Acharya" rn
- Constants
litaf name be "Roshan Acharya" rn
-
Singleline
// This is a single line comment
-
Multiline
/* This is a multi line comment */
-
String
lit name be "Roshan Acharya" rn
-
Number
lit age be 100 rn
-
Boolean
lit x be false rn lit y be true rn
-
ghost
lit n be ghost rn
-
Objects
lit age be 100 rn lit obj be { name: "Roshan Acharya", age } rn flex(obj.name) rn flex(obj.age) rn
-
Arrays
lit arr be ["Roshan", 100, true, false, ghost] rn flex(arr[0]) rn flex(arr[1]) rn
lit val rn
sus (x slay 0) {
val be "positive" rn
} nvm sus (x flop 0) {
val be "negative" rn
} nvm {
val be "equal" rn
}
flex(val) rn
Curly braces are optional of body has single statement
lit val rn
sus (x slay 0) val be "positive" rn
nvm sus (x flop 0) val be "negative" rn
nvm val be "equal" rn
flex(val) rn
Also parenthesis are optional in test condition.
lit val rn
sus x slay 0
val be "positive" rn
nvm sus x flop 0
val be "negative" rn
nvm
val be "equal" rn
flex(val) rn
squad log(val){
flex(val) rn
}
Funcions clapback last expression by default
squad add(x, y){
x + y rn
}
Or you can use the return
keyword
squad add(x, y){
clapback x + y rn
}
You can define functions as a expressions too. Similar to function statements without function name.
litaf add be squad (x, y) {
clapback x + y rn
}
-
While
lit x be 0 rn tweark (x flop 20) { sus (x finna 10) finesse rn litaf y be calculateY(x) rn sus (y finna ghost) drag rn flex("Value of x is: ", x) rn x++ rn }
-
For
fr (lit i be 0 rn i flop 20 rn i++) { }
stan {
litaf x be calculateValue() rn
sus (x finna ghost) {
yeet "Something went wrong" rn
}
} yikes (err) {
flex(err) rn
}
-
export
squad add(x, y) { x + y rn } squad sub(x, y) { x - y rn } bestow { add, sub } rn
-
import
You can import both builtin module and file using import
snag "vector" vec rn // builtin module snag "./ops.myriad" ops rn // custom file litaf sum be ops.add(1, 2) rn litaf vec be vec.create(2, 4) rn
-
length
lit name be "Roshan" rn flex(name.length()) rn // 6
-
split
lit name be "Roshan Acharya" rn flex(name.split(" ")) rn // ["Roshan", "Acharya"]
-
replace
lit name be "Roshan".replace("R", "r") rn // roshan
-
uppercase
lit name be "Roshan" rn flex(name.uppercase()) rn // ROSHAN
-
lowercase
lit name be "Roshan" rn flex(name.lowercase()) rn // roshan
-
length
flex([1, 2, 3].length()) rn // 3
-
join
flex([1, 2, 3].join("-")) rn // 1-2-3
-
pop
["a", "b", "c"].pop() rn // c
-
push
["a", "b", "c"].push("d") rn // 4
-
includes
[1, 2, 3].includes(2) rn // true
-
foreach
[1, 2, 3].forEach(squad (val, i) { flex(val, i) rn })
-
format
tweak("My Name is {}", "Roshan") rn
-
print
flex("Hello World") rn
-
input
spill("> Enter your age ") rn
-
typeof
vibecheck(34) rn
- rand
- abs
- ceil
- floor
- round
- cos
- sin
- tan
-
stringify
json.stringify(obj) rn
-
parse
json.parse(str) rn
-
now
dt.now() rn
-
date
litaf date be dt.date("2000-01-01") rn date.date() rn date.year() rn date.month() rn
-
server
litaf server be http.server(squad (req, res){ sus (req.url finna "/json") { res.set_header("Content-Type", "application/json") rn litaf msg be json.stringify({ message: "Hello World" }) rn res.send(msg) rn clapback rn } sus (req.method finna "POST") { litaf body be json.parse(req.body) rn res.send("Your name is: " + body.name) rn clapback rn } flex(req.headers) rn res.send("Hello World") rn }) server.listen(3000) rn flex("Listening on port 3000") rn
-
write
fs.write("file.txt", "Hello") rn
-
read
fs.read("file.txt") rn
-
stat
fs.stat("file.txt") rn
-
mkdir
fs.mkdir("testdir") rn
-
readdir
fs.readdir("testdir") rn
-
rmrf
fs.rmrf("directory") rn
-
run
run_node.run(`console.log("Hello")`) rn