-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.sr
42 lines (37 loc) · 929 Bytes
/
app.sr
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
enum Option: Some(int32) | None
struct Vector(
x :: int32,
y :: int32,
z :: int16,
w :: int32,
a :: int8,
b :: int16,
l :: int16,
planet :: string
)
fun main() {
vector := %Vector(20, 19, 18i16, 17, 16i8, 15i16, 14i16, "Earth")
x := 40
if 20+20 == x {
printf("20+20 indeed equals %d!\n", x)
return
} else {
printf("20+20 does not equal %d!\n", x)
}
print_vector(vector)
}
fun print_vector(vector :: Vector) {
printf("X: %d\n", vector.x)
printf("Y: %d\n", vector.y)
printf("Z: %d\n", vector.z)
printf("W: %d\n", vector.w)
printf("A: %d\n", vector.a)
printf("B: %d\n", vector.b)
printf("L: %d\n", vector.l)
printf("Planet: %s\n", vector.planet)
}
//fun greet(str :: string) science
//"Hello" => printf("Hi!\n")
//"Goodbye" => printf("Bye!\n")
//name => printf("Hello, %s!\n", name)
external<C> fun printf(i8*, ...)