// function *foo(x) {
// var y = x * (yield)
// return y
// }
// var it = foo(6)
// it.next()
// var res = it.next(7)
// console.log(res.value)
// function *foo(x) {
// var y = x * (yield "Hello")
// return y
// }
// var it = foo(6)
// var res = it.next()
// console.log(res.value)
// console.log(it.next.toString())
// res = it.next(7)
// console.log(res.value)
// function *foo() {
// var x = yield 2
// z++
// var y = yield(z * x)
// console.log(x, y , z)
// }
// var z = 1
// var it1 = foo()
// var it2 = foo()
// var val1 = it1.next().value
// var val2 = it2.next().value
// console.log(val1, val2, z)
// val1 = it1.next(val2 * 10).value
// val2 = it2.next(val1 * 5).value
// console.log(val1, val2, z)
// it1.next(val2 / 2)
// it2.next(val1 / 4)
var a = 1
var b = 2
function *foo() {
a++;
yield;
b = b * a;
a = (yield b) + 3
}
function *bar() {
b--;
yield;
a = (yield 8) + b
b = a * (yield 2)
}
function step(gen) {
var it = gen()
var last
return function() {
last = it.next(last).value
}
}
a = 1
b = 2
var s1 = step(foo)
var s2 = step(bar)
s1()
s1()
s1()
console.log(a)
s2()
s2()
s2()
s2()
console.log(a, b)
console