lang/interpret_test/TestAstFunc2/complex-example.txtar
raw| 1 | -- main.mcl -- |
| 2 | import "fmt" |
| 3 | import "iter" |
| 4 | |
| 5 | # function expression |
| 6 | $id1 = func($x str) { # definition site |
| 7 | $x |
| 8 | } |
| 9 | $id2 = func($x str) { |
| 10 | $x + $x |
| 11 | } |
| 12 | |
| 13 | $generate = func($idn) { |
| 14 | $idn("foo") # 1 call site, 2 calls |
| 15 | } |
| 16 | |
| 17 | $foo = iter.map([$id1, $id2,], $generate) |
| 18 | |
| 19 | $name0 = $foo[0] || "fail" |
| 20 | $name1 = $foo[1] || "fail" |
| 21 | test "${name0}" {} |
| 22 | test "${name1}" {} |
| 23 | -- OUTPUT -- |
| 24 | Vertex: test[foo] |
| 25 | Vertex: test[foofoo] |