lang/interpret_test/TestAstFunc2/map-iterator4.txtar
raw| 1 | -- main.mcl -- |
| 2 | import "golang" |
| 3 | import "iter" |
| 4 | |
| 5 | $ins = ["a", "bb", "ccc", "dddd", "eeeee",] |
| 6 | |
| 7 | # the inline lambda format is more readable with the func as the second arg |
| 8 | $out = iter.map($ins, func($x) { |
| 9 | len($x) |
| 10 | |
| 11 | }) |
| 12 | |
| 13 | $t = golang.template("out: {{ . }}", $out) |
| 14 | |
| 15 | test "${t}" {} |
| 16 | -- OUTPUT -- |
| 17 | Vertex: test[out: [1 2 3 4 5]] |