proposal-pipeline-operator-for-function-composition icon indicating copy to clipboard operation
proposal-pipeline-operator-for-function-composition copied to clipboard

How does this work with multiple generators?

Open tabatkins opened this issue 7 years ago • 1 comments
trafficstars

The introduction of a generator into the pipeline implicitly invokes some looping, producing a generator as output. But what happens when you pipeline together two generators?

Like, say you have:

function* range(n) { for(const i = 0; i < n; i++) yield n; }
function* fbb(n) { yield "foo"+n; yield "bar"+n; yield "baz"+n; }

const what = range +> fbb +> (x=>console.log(x));
what(5); // what happens?

Does this implicitly loop twice, calling the final function 15 times in total?

tabatkins avatar Mar 12 '18 16:03 tabatkins

Yes exactly.

TheNavigateur avatar Mar 12 '18 18:03 TheNavigateur