[프로그래밍 루아] 코루틴(coroutine) 연습
--consumer-driven design function receive() local status, value = coroutine.resume(producer) return value end function send(x) coroutine.yield(x) end producer = coroutine.create( function () while true do local x = io.read() send(x) end end) consumer = function () while true do local x = receive() print(x) end end consumer() --fibonacci co = coroutine.create(function(n, lhs, rhs) while true do n..
프로그래밍/Lua 2017. 11. 14. 16:41