mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-24 00:00:17 +00:00
CPunch
8ac8085d20
- 'var' has some weird scoping connotations with users of JS. better to change it to 'let', which will decide whether to make the variable a local or a global - 'func' looks visually appealing lol - some minor refactoring done in cparse.c
29 lines
490 B
Plaintext
29 lines
490 B
Plaintext
proto test
|
|
func __init(self, x)
|
|
self:setArg(x)
|
|
end
|
|
|
|
func __tostring(self)
|
|
let total = 1
|
|
|
|
for (let i = self.x; i > 0; i = i - 1) do
|
|
total = total * i;
|
|
end
|
|
|
|
return "The factorial of " .. self.x .. " is " .. total
|
|
end
|
|
|
|
func setArg(self, x)
|
|
self.x = x
|
|
end
|
|
end
|
|
|
|
let t = test(1)
|
|
|
|
for (let x = 1; x < 1000; x = x + 1) do
|
|
for (let i = 1; i < 100; i = i + 1) do
|
|
t:setArg(i)
|
|
|
|
print(t)
|
|
end
|
|
end |