Hi,

Probably this is a silly question… 
In lua, I have an array named  t which is determined in a piece of lua code, 
having (say) two columns and I want to extract for example the first column of 
t and call the new array tt.
In Matlab, Scilab and friends, this can done by saying tt = t[:,1].

Is this possible in lua?
For the moment I have something like this, but I think it is not a good 
approach:

\starttext
\startluacode
        t = {}  -- a silly example of a matrix...
        for i = 1, 3 do
                t[i] = {}
                t[i]["columnOne"] = 10*i + 1
                t[i]["columnTwo"] = 10*i + 2
        end
        tt = {}
        for i = 1,3 do -- is it possible to avoid this ?
                tt[i] = t[i]["columnOne"]
        end
\stopluacode

The first column of the array  \type{t} is: 
\ctxlua{context.print(tt," ; ")}
\stoptext

Many thanks for any help,
Best regards: OK
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to