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.
%%%%%%%%
\starttext
\startluacode
  printMatrix = function (t)
        context.startmatrix{left = "\\left(\\,", right = "\\,\\right)"}
        for _, r in ipairs(t) do
                for _, c in ipairs(r) do
                        context.NC(c)
                end
                context.NR()
        end
        context.stopmatrix()
end
\stopluacode

\startformula
\startluacode
local 
mat={{"a_{11}","a_{12}","a_{13}"},{"a_{21}","a_{22}","a_{23}"},{"a_{31}","a_{32}","a_{33}"}}
printMatrix(mat)
\stopluacode
\stopformula
\stoptext

%%%%%%%%%%%%%

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.  

  function printMatrixA()
        context.startmatrix{left = "\\left(\\,", right = "\\,\\right)"}
        for i=1,3 do
                for j=1, 3 do
                        context.NC("a_{ij}")
                end
        context.NR()
        end
        context.stopmatrix()
  end

%%%%%%%%%%%%%%%

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
___________________________________________________________________________________

Reply via email to