diff --git a/exl/00_variables.fzs b/exl/00_variables.fzs new file mode 100644 index 0000000..fe3b019 --- /dev/null +++ b/exl/00_variables.fzs @@ -0,0 +1,32 @@ +// There are two ways to work with variables +// 1. Declare variable: +str someString = "world, hello!"; + +// 2. Change variable value: +someString = "hello, world!"; + +// Variables helps you store values to use it later +int a = 2; +int b = a + a * a; +int c = a * b; + +printline("Now we got 12:"); +printline(c); + +// Also, there is many different types to help your program +// work with many things: +int signedInteger; +uint unsignedInteger +str string; +bool boolean; + +i8 integer1; // 8-byte int +i16 integer2; // 16-byte int +i32 integer3; // 32-byte int +i64 integer4; // 64-byte int + +u8 integer5; // unsigned 8-byte integer +u16 integer6; // unsigned 16-byte integer +u32 integer7; // unsigned 32-byte integer +u64 integer8; // unsigned 64-byte integer + diff --git a/exl/01_conditions.fzs b/exl/01_conditions.fzs new file mode 100644 index 0000000..1a73b9d --- /dev/null +++ b/exl/01_conditions.fzs @@ -0,0 +1,30 @@ +// When you need to check some value +// a conditional statements might help you + +int valueToCheck = 2 + 2; +if (valueToCheck == 4) +{ + printline("Yay! 2 + 2 = 4"); +} + +// Conditional statement uses condition in pairs +// after `if` keyword and executes command(s) after +// if condition turns out to be true + +// Otherwise, to execute block when condition turns +// out to be false, you can use `else` keyword: + +int age = 30; + +if (age <= 20) + printline("You're too young"); +else +{ + age = 20; + printline("You looks too young!"); +} + +// NOTE: If you need to execute only one statement +// inside `if` or `else` block, then the curly +// braces can be omitted. + diff --git a/exl/02_functions.fzs b/exl/02_functions.fzs new file mode 100644 index 0000000..1c4ea5b --- /dev/null +++ b/exl/02_functions.fzs @@ -0,0 +1,30 @@ +// If you have some code section which is +// duplicated in program several times +// then it means your program needs some +// functions! + +fn doSomeWork() +{ + printline("Some work"); +} + +// If the function makes some kind of +// calculations then you should specify +// the result type + +fn sum(int a, int b) int +{ + return a + b; +} + +// The `return` keyword can be used to +// actually return the value from the +// function. Also, you can specify list +// of arguments that you will use inside +// the function + +int first = 5; +int second = 6; +int result = sum(first, second); +printline(result); +