This adds the Unify method to our map function and also switches the arg order because I decided it would look nicer. Completely untested.
28 lines
595 B
Plaintext
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($in1, $fn) # XXX: change to map
|
|
$out2 = iter.xmap($in2, $fn) # XXX: change to map
|
|
$out3 = iterxmap($in1, $fn) # XXX: change to map
|
|
$out4 = iterxmap($in2, $fn) # 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 {}
|