func HelloWorld() {
PrintLine("Hello, world!");
}
HelloWorld();
wuzh.exe
- interpreter (link)
*.wuzh
- file extensions
x := 4;
const PI := 3.14;
x = 21 * 2;
# Unit
u := unit;
# Integer
x := 42;
l := 1_000_000;
# Double
y := 3.14;
# String
z := "Hello";
# Boolean
a := true;
# Array
b := [1, "two", 3.14];
range := [1..10];
# Dictionary
d := {
"name": "Vlad",
"age": 19
};
String str := "string";
Any str2 := "string2"; # str2 type is String
func Function(Int a, Int b) -> Int {
return a * b;
}
func Function2(Any a, Any b) -> Any {
return a + b;
}
func Function3(a, b) {
return a / b;
}
arr := [1, 2, 3];
x := arr[0]; # x = 1
str := "Hello";
c := str[0]; # c = "H"
dict := {
"name": "Vlad",
"age": 19
};
d := dict["name"]; # d = "Vlad"
# Index assignment
arr[0] = 3;
str[0] = "B";
dict["name"] = "Bob";
dict["height"] = "180cm";
if (x > 30) {
PrintLine("x is greater than 30");
} else {
PrintLine("x is less than or equal to 30");
}
while (x > 0) {
PrintLine(x);
x = x - 1;
}
for (i := 0, i < 5, i = i + 1) {
PrintLine(i);
}
arr := [1, 2, 3, 4, 5];
for (item in arr) {
PrintLine(item);
}
# Range from 1 to 10
for (i in [1..10]) {
PrintLine(i);
}
str := "Hello, world!";
for (c in str) {
PrintLine(c);
}
func add(a, b) {
return a + b;
}
func mult(Int a, Int b) -> Int {
return a * b;
}
func factorial(n)
{
if(n == 0)
{
return 1;
}
else
{
return n * factorial(n - 1);
}
}
# Return type is Unit
func printName(name) {
PrintLine(name);
}
result := add(3, 4);
# > < >= <= == !=
if (x > y) {
PrintLine("x is greater than y");
}
if (a == b) {
PrintLine("a is equal to b");
}
# Operations on numbers: + - * / // %
number := (1 + 2 * 3) / 2; # number = 3.5
# Operations on arrays: +
arrConcat := [1, 2] + [3, 4]; # arrConcat = [1, 2, 3, 4]
# String operations: + *
strConcat := "Hello" + " " + "world!"; # strConcat = "Hello world!"
strRepeat := "Hello" * 3; # strRepeat = "HelloHelloHello"
The Wuzh language supports the following types:
Unit
: Empty type, void analogInteger
Double
String
Boolean
Array
Dictionary
Any
: Auto-detects type in variables, means any type in function parameters and return type
List of functions in the standard library: StdLib/