Otared Kavian schrieb am 24.08.2023 um 01:04:___________________________________________________________________________________
Hi Fabrice,As Wolfgang points out, it is indeed possible to fill-in your table with Lua: maybe you were wondering how to fill the columns 2, 3 and 4. In this case you need to use the Lua function math.mod as in the following, which is a completed version of what Wolfgang sent:
I guess I completely missed the units digit part :)
%% begin filling-with-lua.tex\starttext\startluacodecontext.startxtable{ align = "middle,lohi", bodyfont = "9pt", framecolor = "black" }context.startxrow{ background = "color", backgroundcolor = "lightgray" }context.startxcell{ nx = 4 }context("Units digit of")context.stopxcell()context.stopxrow()context.startxrow()context.startxcell{ width = "1cm" }context.im("a")context.stopxcell()context.startxcell{ width = "1cm" }context.im("a^2")context.stopxcell()context.startxcell{ width = "1cm" }context.im("b")context.stopxcell()context.startxcell{ width = "1cm" }context.im("2b^2")context.stopxcell()context.stopxrow()for i = 0,9 docontext.startxrow()for j = 1,4 docontext.startxcell()if j == 1 thencontext(i)elseif j == 2 thencontext(math.mod(i*i,10))elseif j == 3 thencontext(i)elsecontext(math.mod(2*i*i,10))endcontext.stopxcell()endcontext.stopxrow()end
I would drop the column check in this case.
for i = 0,9 do
context.startxrow()
context.startxcell()
context(i)
context.stopxcell()
context.startxcell()
context(math.mod(i*i,10))
context.stopxcell()
context.startxcell()
context(i)
context.stopxcell()
context.startxcell()
context(math.mod(2*i*i,10))
context.stopxcell()
context.stopxrow()
end
Wolfgang
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________