Replaces the value of an item at the specified index, returning the new iterable set
function updateAt(index, value) {
    return function* (source) {
        let i = 0;
        for (const item of source) {
            if (i === index) {
                yield value;
            }
            else {
                yield item;
            }
            i = i + 1;
        }
    };
}