Debian Codegraph @

lang/interpret_test/TestAstFunc2/changing-func.txtar

raw
1 -- main.mcl --
2 # this can return changing functions, and could be optimized, too
3 func funcgen($b) {
4 if $b {
5 func() {
6 "hello"
7 }
8 } else {
9 func() {
10 "world"
11 }
12 }
13 }
14
15 $fn1 = funcgen(true)
16 $fn2 = funcgen(false)
17
18 $out1 = $fn1()
19 $out2 = $fn2()
20
21 test "${out1}" {}
22 test "${out2}" {}
23 -- OUTPUT --
24 Vertex: test[hello]
25 Vertex: test[world]