-
Notifications
You must be signed in to change notification settings - Fork 0
/
function_example.gotl
66 lines (45 loc) · 926 Bytes
/
function_example.gotl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Valar Morghulis
Rglor: @printHello() {
Jon: -- "Hello";
}
Rglor: @printArg(arg) {
Jon: -- "arg: " -- arg;
}
Daeneris: c = "This is c";
Rglor: @sum(a, b) {
Daeneris: c = Tyrion: a + b;
return c;
}
Rglor: @max(a, b) {
Cercei: if (a > b) {
return a;
}
return b;
}
@printHello();
@printArg(c);
Jon: -- "Enter a";
Ygritte: -- a;
Jon: -- "Enter b";
Ygritte: -- b;
Jon: -- "Sum: " -- @sum(a, b);;
Jon: -- "Max: " -- @max(a, b);;
@printArg(c);
Rglor: @findCircumference(r) {
Daeneris: pi = 3;
Daeneris: res = Tyrion: 2 * pi * r;
return res;
}
Jon: -- "Enter radius:";
Ygritte: -- r;
Jon: -- "Circumference: " -- @findCircumference(r);;
Rglor: @someFunc() {
Jon: -- "@someFunc call";
}
Rglor: @someFuncCaller() {
Jon: -- "@someFuncCaller call";
@someFunc();
}
Jon: -- "Example of calling function from other function:";
@someFuncCaller();
Valar Dohaeris