Commit 143eb425 authored by nanahira's avatar nanahira

Revert "revert underscore"

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