Files
mgmt/lang/interpret_test/TestAstFunc2/map-iterator1/main.mcl
James Shubin 0be4b86230 lang: funcs: core: iter: Add map iterator function
Sadly this doesn't all work yet, but the tests and xmap function are
approximately correct. Eventually we add filter and reduce too!
2022-08-04 14:23:16 -04:00

28 lines
595 B
Plaintext

import "iter"
func iterxmap($a, $b) { # XXX: change to map
iter.xmap($a, $b) # XXX: change to map
}
$fn = func($x) {
$x + $x
}
$in1 = [5, 4, 3, 2, 1,]
$in2 = ["a", "b", "c", "d", "e",]
$out1 = iter.xmap($fn, $in1) # XXX: change to map
$out2 = iter.xmap($fn, $in2) # XXX: change to map
$out3 = iterxmap($fn, $in1) # XXX: change to map
$out4 = iterxmap($fn, $in2) # XXX: change to map
$t1 = template("out1: {{ . }}", $out1)
$t2 = template("out2: {{ . }}", $out2)
$t3 = template("out3: {{ . }}", $out3)
$t4 = template("out4: {{ . }}", $out4)
test $t1 {}
test $t2 {}
test $t3 {}
test $t4 {}