1 (function init-counter [
2 (default-space:space-address <- new space:literal 30:literal)
3 (n:integer <- next-input)
4 (reply default-space:space-address)
7 (function increment-counter [
8 (default-space:space-address <- new space:literal 30:literal)
9 (0:space-address/names:init-counter <- next-input) ; setup outer space; it *must* come from 'init-counter'
10 (x:integer <- next-input)
11 (n:integer/space:1 <- add n:integer/space:1 x:integer)
12 (reply n:integer/space:1)
16 (default-space:space-address <- new space:literal 30:literal)
18 (a:space-address <- init-counter 34:literal)
20 (b:space-address <- init-counter 23:literal)
21 ; increment both by 2 but in different ways
22 (increment-counter a:space-address 1:literal)
23 (bres:integer <- increment-counter b:space-address 2:literal)
24 (ares:integer <- increment-counter a:space-address 1:literal)
26 ($print (("Contents of counters a: " literal)))
27 (print-integer nil:literal/terminal ares:integer)
28 ($print ((" b: " literal)))
29 (print-integer nil:literal/terminal bres:integer)
30 ($print (("\n" literal)))
33 ; compare http://www.paulgraham.com/accgen.html