On 1/8/2026 9:27 PM, Jeong Dal via ntg-context wrote:
\usemodule[m-matrix]
\startluacode
mtx = moduledata.matrix
\stopluacode
this gives a warning so what you want is
\starttext
\startluacode
local mtx = moduledata.matrix
local matT = {{0,0,1,1/3},{1,0,0,1/3},{0,1/2,0,1/3},{0,1/2,0,0}}
local matOld = {{1/4},{1/4},{1/4},{1/4}}
local matNew = {}
local matHistory = {}
table.insert(matHistory, matOld)
for i = 2, 5 do
matOld = matHistory[i-1]
matNew = mtx.product(matT, matOld)
mtx.typeset(matT)context("\\times")mtx.typeset(matOld)
context(" = ") mtx.typeset(matNew) context("\\blank")
table.insert(matHistory, matNew)
end
table.save("tempList.lua", matHistory)
\stopluacode
\startMPcode
numeric u,i,j; u := 1cm;
pair A[];
path p;
lua("MP = { } MP.data = table.load('tempList.lua')") ;
for i = 1 upto 3:
j := i*u;
A[i] := (decimal j,lua("MP.data[" & decimal i & "][1]"));
label(textext("A"),A[i]);
endfor;
\stopMPcode
\stoptext
your "decimal j" makes string while a number is expected
here mp.print is clever enough to return a number
\startMPcode
numeric u; u := 1cm;
lua("MP = { } MP.data = table.load('tempList.lua')") ;
for i = 1 upto 3:
label(textext("A"),(
i*u,
lua("mp.print(MP.data[" & decimal i & "][1])")
));
message(lua("mp.print(MP.data[" & decimal i & "][1])"));
endfor;
\stopMPcode
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________