![](https://secure.gravatar.com/avatar/d7c3317235884569312c31f786d43bbc.jpg?s=120&d=mm&r=g)
Hi Wolfgang, Thank you so much Fabrice Le jeu. 24 août 2023 à 19:46, Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> a écrit :
Otared Kavian schrieb am 24.08.2023 um 12:50:
On 24 Aug 2023, at 06:03, Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> wrote:
[…]
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
Indeed this is much more elegant… It feels so good to be on this list and learn from such insights :-)
We don't even need the math.mod function because Lua added with version 5.1 a modulo operator, the loop to create the row can now be changed to
for i = 0,9 do context.startxrow() context.startxcell() context(i) context.stopxcell() context.startxcell() context(i * i % 10) context.stopxcell() context.startxcell() context(i) context.stopxcell() context.startxcell() context(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
___________________________________________________________________________________