|
Lua 5.4.7 on HP Prime +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (https://www.hpmuseum.org/forum/forum-3.html) +--- Forum: HP Prime (https://www.hpmuseum.org/forum/forum-5.html) +--- Thread: Lua 5.4.7 on HP Prime (/thread-25504.html) |
Lua 5.4.7 on HP Prime - SQY - 2026-10-01 17:19 Lua programs can now be run on the HP Prime. With DeepSeek's help, the original Lua 5.4.7 was ported to the calculator. Note: only G1 with firmware 20250915 can use it. How to use: Transfer primeLua.hpappdir to the calculator to launch it. Tap to execute a Lua program. It is recommended to use PrimeCode 1.1 or later to edit Lua code on the calculator; it provides Lua highlighting support. In actual tests, primeLua's memory leak is extremely small, ranging from 1–10K. By comparison, primeLua drops ~2 MB of memory every time it compiles + executes. Let's start What is Lua? 撸啊 Write your first primeLua program: Print a line of text: hello, primeLua! Code: print("hello, primeLua!")Below is a small program I wrote to calculate pi using the Monte Carlo method; it draws the simulation process on the screen. Code: gfx.init()
gfx.clear(gfx.BLACK)
count = 0
color = 0
for i=1, 100000000 do
x, y = math.random(), math.random()
if xx + yy <= 1 then
count = count + 1
color = gfx.BLUE
else
color = gfx.WHITE
end
gfx.pixel(x240, y240, color)
if i % 20000 == 0 then
gfx.textbg(240, 0, tostring(4 * count / i), gfx.WHITE, gfx.BLACK)
end
end
print(count * 4)
sys.sleep(5000)![]() I ran a performance test, using a single calculation on a Casio calculator as the baseline. The values here are the number of summations computed by the Chinese Edition Casio fx 991 CNX. It can compute 562.5 summations per second. Code: time micropython primeLua ZSE-TILua-CX
zeta(2) 1e6 13371 3270 11407
fib(32) 10364 3295 ?below is the document. |