lang/interpret_test/TestAstFunc2/lambda-scope-args.txtar
raw| 1 | -- main.mcl -- |
| 2 | import "fmt" |
| 3 | |
| 4 | # test a function with part of the expression scoped from outside |
| 5 | $c1 = 42 # put this after to confirm any-order rules |
| 6 | $constmult = func($x) { |
| 7 | $c1 * $x * $c2 |
| 8 | } |
| 9 | $c2 = 37 # put this after to confirm any-order rules |
| 10 | |
| 11 | $num = 13 |
| 12 | $out = $constmult($num) # 20202 |
| 13 | |
| 14 | test [fmt.printf("%d * %d * %d is %d", $c1, $num, $c2, $out),] {} |
| 15 | -- OUTPUT -- |
| 16 | Vertex: test[42 * 13 * 37 is 20202] |