Commit d85f4387 authored by nanahira's avatar nanahira

Revert "Revert "revert underscore""

This reverts commit 143eb425.
parent 143eb425
...@@ -37,11 +37,12 @@ end ...@@ -37,11 +37,12 @@ end
function Underscore.iter(list_or_iter) function Underscore.iter(list_or_iter)
if type(list_or_iter) == "function" then return list_or_iter end if type(list_or_iter) == "function" then return list_or_iter end
local i = 0
return function() return coroutine.wrap(function()
i = i + 1 for i=1,#list_or_iter do
return list_or_iter[i] coroutine.yield(list_or_iter[i])
end end
end)
end end
function Underscore.range(start_i, end_i, step) function Underscore.range(start_i, end_i, step)
...@@ -50,11 +51,11 @@ function Underscore.range(start_i, end_i, step) ...@@ -50,11 +51,11 @@ function Underscore.range(start_i, end_i, step)
start_i = 1 start_i = 1
end end
step = step or 1 step = step or 1
local list = {} local range_iter = coroutine.wrap(function()
for i=start_i, end_i, step do for i=start_i, end_i, step do
table.insert(list,i) coroutine.yield(i)
end end
local range_iter = Underscore.iter(list) end)
return Underscore:new(range_iter) return Underscore:new(range_iter)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment