Consider the loop
let r1 = vec![];
let r2 = vec![];
for i in 0..20 {
r1.push(i*i)
r2.push(i*i*i)
}
is there a way to write this as an iterator over i
, whose collect
from the two maps (|i| i*i
and |i| i*i*i
) returns the same semantic content as the for
above and with the same performance?