Commit 143eb425 authored by nanahira's avatar nanahira

Revert "revert underscore"

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