Extracting a column from an array in lua
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
participants (1)
-
Otared Kavian