-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.vsop
37 lines (34 loc) · 939 Bytes
/
Test.vsop
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
class List {
head : int32;
isNil() : bool { true }
length() : int32 { 0 }
head() : int32 { head }
}
(* Nil is nothing more than a glorified alias to List *)
class Nil extends List { }
class Cons extends List {
tail : List;
init(hd : int32, tl : List) : Cons {
head <- hd;
tail <- tl;
self
}
isNil() : bool { false }
length() : int32 { 1 + tail.length() }
next() : List { tail }
}
class Main extends IO {
main() : int32 {
let s : int32 <- 4 in
let xs : Cons <- (new Cons).init(0, (new Cons).init(1, (new Cons).init(2, new Nil))) in {
xs.head();
print("Here");
printInt32(xs.head());
print("Here");
printInt32(xs.next().head());
print("Here");
printInt32(1).printInt32(xs.next().head()).printInt32(xs.length()).printInt32(xs.next().length()) };
print("Here at last");
0
}
}