Yield all items in every iterable returned by the mapper when applied to every item in the source iterable
function flatMap(mapper) {
    return function* (iterable) {
        let index = 0;
        for (const value of iterable) {
            const innerIterable = mapper(value, index);
            for (const inner of innerIterable) {
                yield inner;
            }
            index = index + 1;
        }
    };
}