-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.gs
93 lines (80 loc) · 1.36 KB
/
example.gs
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* GoSci code */
int a = 1;
float vel [m][s -1] = 2.5;
unit U {}
unit km {
1000.0 m
}
vartype Num {
int | float
}
struct Person {
string name;
int age;
}
func gcd(int a, int b) int {
for (a != b) {
if (b < a) {
a = a - b;
} else {
b = b - a;
}
}
return a;
}
func main() int{
int a = 10;
float b = 18.1;
char c;
string s;
bool flag;
int x = (a/5)^3;
int i = 0;
float t [s] = -b;
float acc [m][s -2];
float acc2 [km][s -2];
Num number = 2.5;
Person student;
t = 2.9 * 5.8 ^ 2 / 1.0;
student = Person{"superman", 9999};
student.name = "alice";
student.age = 12;
student.age = student.age + 1;
/* unit auto checking and conversion */
acc = vel / t;
t ^ 3; /* [s 3] */
acc * vel; /* [m 2][s -3] */
acc / acc; /* [] */
acc2 = acc; /* acc / 1000 */
acc = acc2; /* acc2 * 1000 */
acc2 + acc; /* acc / 1000 */
acc + acc2; /* acc2 * 1000 */
c = 'c';
s = "helloworld";
flag = (true && (!false)) || false;
!flag;
for (i = 0; i < a; i=i+1) {
print(i);
}
switch (x+1;x) {
case 1, 2:
return x;
case 3:
break;
default:
return x - 1;
}
match (v := number) {
case int:
v = v + 1;
return v;
case float:
v = v * 2.0;
return -1;
default:
break;
}
print(gcd(3,15));
print(gcd(a,x));
return 0;
}