···
Dear Hans, Lucas, Wolfgang, Aditya
Now, I write a matrix using \startluacode by the helps of you. Also, I can do some operations in matrices which reduced my typing job. In this code, I have to give all the entries of a matrix as a table. It is good to use in many cases.
I have one more question. If the given array is as the following and it works well.
However, there might be a better way to do job using "for" iteration. I tired to use "i, j" in several ways but it doesn't work.
Inside a string the variables are just bytes. To print to a string you can interpolate with string.format() [1]. [1] http://www.lua.org/manual/5.1/manual.html#pdf-string.format ································································· \startluacode document = document or { } -- recommended: use namespace document.print_matrix = function (x, y) if not y then y = x end -- default to square context.startmatrix{left = "\\left(\\,", right = "\\,\\right)"} local schema = "a_{%d%d}" -- %d: prints integer part for i=1, x do for j=1, y do --- use the template defined above to print the --- row and column context.NC(string.format(schema, i, j)) end context.NR() end context.stopmatrix() end \stopluacode \starttext \startformula \ctxlua{document.print_matrix(3)} \stopformula \startformula \ctxlua{document.print_matrix(9,4)} \stopformula \startformula \ctxlua{document.print_matrix(9)} \stopformula \stoptext \endinput ·································································
Is there a way to do such a job using "for" iteration?
Thank you for reading.
Best regards,
Dalyoung ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments