const map = f => xs => ({ [Symbol.iterator]: function * () { for (const x of xs) { yield f(x); } } }); xs |> map(x => x * 2);