Enumerate until index and return the element at index, or consumes and return undefined
function elementAtOrDefault(index, or) {
    return function (it) {
        let i = 0;
        for (const item of it) {
            if (i === index) {
                return item;
            }
            i = i + 1;
        }
        return or;
    };
}