From 97eb971b7574b3f283d7111a567a301faec9912d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 27 Dec 2016 22:20:43 -0800 Subject: 3725 More improvements to cross-linking example programs. Include their own functions as well in the tags for each program, even as you share the core .mu files everywhere. --- html/counters.mu.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'html/counters.mu.html') diff --git a/html/counters.mu.html b/html/counters.mu.html index 6736fb72..c4421907 100644 --- a/html/counters.mu.html +++ b/html/counters.mu.html @@ -57,28 +57,28 @@ if ('onhashchange' in window) { 1 # example program: maintain multiple counters with isolated lexical scopes 2 # (spaces) 3 - 4 def new-counter n:num -> default-space:space [ + 4 def new-counter n:num -> default-space:space [ 5 default-space <- new location:type, 30 6 load-ingredients 7 ] 8 - 9 def increment-counter outer:space/names:new-counter, x:num -> n:num/space:1 [ + 9 def increment-counter outer:space/names:new-counter, x:num -> n:num/space:1 [ 10 local-scope 11 load-ingredients -12 0:space/names:new-counter <- copy outer # setup outer space; it *must* come from 'new-counter' +12 0:space/names:new-counter <- copy outer # setup outer space; it *must* come from 'new-counter' 13 n/space:1 <- add n/space:1, x 14 ] 15 -16 def main [ +16 def main [ 17 local-scope 18 # counter A -19 a:space <- new-counter 34 +19 a:space <- new-counter 34 20 # counter B -21 b:space <- new-counter 23 +21 b:space <- new-counter 23 22 # increment both by 2 but in different ways -23 increment-counter a, 1 -24 b-value:num <- increment-counter b, 2 -25 a-value:num <- increment-counter a, 1 +23 increment-counter a, 1 +24 b-value:num <- increment-counter b, 2 +25 a-value:num <- increment-counter a, 1 26 # check results 27 $print [Contents of counters], 10/newline 28 $print [a: ], a-value, [ b: ], b-value, 10/newline -- cgit 1.4.1-2-gfad0