-
Notifications
You must be signed in to change notification settings - Fork 0
/
DynArray.bismuth
54 lines (34 loc) · 983 Bytes
/
DynArray.bismuth
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
extern func printf(str s, ...) : int;
define func printIdxValue(int[] array, str id, int idx) : Unit
{
var val := array[idx];
match val
| Unit u => printf("%s[%u] = Unit\n", id, idx);
| int i => printf("%s[%u] = %u\n", id, idx, i);
return;
}
define program :: c : Channel<-int> {
int [] a;
# a[0] := 1; # a.length;
# a[0] := 30;
printIdxValue(a, "a", 0); # TODO: Returns 0... interesting
c.send(0)
a[0] := 30;
printIdxValue(a, "a", 0);
a[21] := a.length;
printIdxValue(a, "a", 1);
for(int i := 0; i < a.length; i := i + 1)
{
printIdxValue(a, "a", i);
}
# Channel<-int>[] channel_array;
# channel_array[0] := c;
# for(int i := 0; i < channel_array.length; i := i + 1)
# {
# printf("%u\n", i);
# var a := channel_array[i];
# match a
# | Unit u => {}
# | Channel<-int> a => { a.send(0); }
# }
}