lang/interpret_test/TestAstFunc2/simple-scoped-lambda.txtar
raw| 1 | -- main.mcl -- |
| 2 | # this can return changing functions, and could be optimized, too |
| 3 | $funcgen = func() { |
| 4 | func($b) { |
| 5 | if $b { |
| 6 | "hello" |
| 7 | } else { |
| 8 | "world" |
| 9 | } |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | $fn = $funcgen() |
| 14 | $out1 = $fn(true) |
| 15 | $out2 = $fn(false) |
| 16 | |
| 17 | test "${out1}" {} |
| 18 | test "${out2}" {} |
| 19 | -- OUTPUT -- |
| 20 | Vertex: test[hello] |
| 21 | Vertex: test[world] |