- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiterator.lua
More file actions
Latest commit
21 lines (18 loc) · 452 Bytes
/
Copy pathiterator.lua
File metadata and controls
21 lines (18 loc) · 452 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
localIterator= {}
--- creates an iterator container
-- example `Iterator.new(pairs(my_table))`
functionIterator.new(gen, param, state)
return {
gen,
param,
state
}
end
-- returns the next element in the iterator, or nil if no more elements exist
functionIterator._next(iter)
localgen, param, state=unpack(iter)
localvals= {gen(param, state)}
iter[3] =vals[1]
returnvals
end
returnIterator