'map' function error with different length iterators


#1

Map function when applied on different length iterators throws a DimensionMismatch error while it works perfectly fine when applied to infinite length iterators.

The strategy of map in case of infinite length iterator can be generalised as well to different length iterators i.e. to apply map element wise and return array whose size is minimum of the two.


#2

A strategy suggested by @tim.holy was to implement Iterators.truncate(y, x) function which will truncate longer y iterator to the size of x.


#3

Note IterTools.shortest which I think implements the trait selection you are looking for.


#5

The map function makes a call to promote_shape which works differently while we need to compare the two iterators length and return one with the less length.