Commit d85f4387 authored by nanahira's avatar nanahira

Revert "Revert "revert underscore""

This reverts commit 143eb425.
parent 143eb425
......@@ -37,11 +37,12 @@ end
function Underscore.iter(list_or_iter)
if type(list_or_iter) == "function" then return list_or_iter end
local i = 0
return function()
i = i + 1
return list_or_iter[i]
end
return coroutine.wrap(function()
for i=1,#list_or_iter do
coroutine.yield(list_or_iter[i])
end
end)
end
function Underscore.range(start_i, end_i, step)
......@@ -50,11 +51,11 @@ function Underscore.range(start_i, end_i, step)
start_i = 1
end
step = step or 1
local list = {}
for i=start_i, end_i, step do
table.insert(list,i)
end
local range_iter = Underscore.iter(list)
local range_iter = coroutine.wrap(function()
for i=start_i, end_i, step do
coroutine.yield(i)
end
end)
return Underscore:new(range_iter)
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