https://github.com/akkartik/mu1/blob/master/counters.mu
1
2
3
4 def new-counter n:num -> default-space:space [
5 default-space <- new location:type, 30
6 load-inputs
7 ]
8
9 def increment-counter outer:space/names:new-counter, x:num -> n:num/space:1 [
10 local-scope
11 load-inputs
12 0:space/names:new-counter <- copy outer
13 n/space:1 <- add n/space:1, x
14 ]
15
16 def main [
17 local-scope
18
19 a:space/names:new-counter <- new-counter 34
20
21 b:space/names:new-counter <- new-counter 23
22
23 increment-counter a, 1
24 b-value:num <- increment-counter b, 2
25 a-value:num <- increment-counter a, 1
26
27 $print [Contents of counters], 10/newline
28 $print [a: ], a-value, [ b: ], b-value, 10/newline
29 ]