mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-12-29 20:50:05 +00:00
Added dictionary support to OP_ITER
ISTRING_RESERVED was added to iStrings call & callCFunction now use memmove instead of memcpy Additionally, added cosmoO_setUserP, cosmoO_getUserP, cosmoO_setUserI and cosmoO_getUserI to the C API.
This commit is contained in:
@@ -8,4 +8,4 @@ end
|
||||
|
||||
for (var i = 1; i < 40; i++) do
|
||||
print("The fib number of " .. i .. " is " .. fib(i))
|
||||
end
|
||||
end
|
||||
@@ -15,6 +15,20 @@ proto Vector
|
||||
function __index(self, key)
|
||||
return self.vector[key]
|
||||
end
|
||||
|
||||
function __iter(self)
|
||||
self.iterIndex = 0
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function __next(self)
|
||||
if self.iterIndex > self.x then
|
||||
return nil
|
||||
end
|
||||
|
||||
return vector[self.iterIndex++]
|
||||
end
|
||||
end
|
||||
|
||||
var vector = Vector()
|
||||
@@ -23,6 +37,6 @@ for (var i = 0; i < 100000; i++) do
|
||||
vector.push(i)
|
||||
end
|
||||
|
||||
for (var i = 0; i < 100000; i++) do
|
||||
print(vector.pop() .. " : " .. vector[i])
|
||||
for i in vector do
|
||||
print(i)
|
||||
end
|
||||
Reference in New Issue
Block a user