alestane icon

FIltered iterator

alestane | PRO | 01/25/13 06:19:15 PM UTC | 0 ⭐ | 288 👁️ | Never ⏰ | []
Lua |

250 B

|

None

|

0 👍

/

0 👎

function filterLines(filter, source, ...)
    local supply = coroutine.wrap(
        function(filter, ...)
            for line in ... do
                if filter(line) then
                    coroutine.yield(line)
                end
            end
        end
    )
    supply(filter, source, ...)
    return supply
end

Comments