mirror of
https://github.com/zekexiao/pocketlang.git
synced 2025-03-04 13:15:55 +08:00

- Warnings were fixed - Libraries are registered internally when PKVM created and cleanedup when PKVM freed (if PK_NO_LIBS not defined) - Lang.clock() moved to time module and sleep, epoch time were added. - Support both upper case and lower case hex literals - Support hex excaped characters inside strings (ex: "\x41") - Native api for import modules added `pkImportModule(...)` - pkAllocString, pkDeallocString are changed to pkRealloc. - NewInstance, DeleteInstance functions now take PKVM however delete function should not allocate any memory since it's invoked at the GC execution.
19 lines
301 B
Plaintext
19 lines
301 B
Plaintext
from time import clock
|
|
|
|
def is_prime(n)
|
|
if n < 2 then return false end
|
|
for i in 2..n
|
|
if n % i == 0 then return false end
|
|
end
|
|
return true
|
|
end
|
|
|
|
start = clock()
|
|
N = 30000; primes = []
|
|
for i in 0..N
|
|
if is_prime(i)
|
|
list_append(primes, i)
|
|
end
|
|
end
|
|
print("elapsed:", clock() - start, "s")
|