[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to create multi-dimensional table in C?
- From: "Michael Newberry" <mnewberry@...>
- Date: Mon, 10 Aug 2009 17:11:40 -0700
I want to create a 2-D table (array) in C to return to a lua script. In
other words, a={} and b = {}, then a[1] = b, a[2] = b, etc., for each new b.
I can't figure out how to assign each "column" table to an element of the
"row" table, like a[1] = b. My gut tells me to do something like the
following, but this code hits a dead end:
lua_newtable( L ); // push a Row Table (the main table) onto the stack
for ( int j = 1; j <= nRows; j++ )
{
lua_newtable( L ); // push a Column Table onto the stack
for ( int i = 1; i <= nCols; i++ )
{
lua_pushnumber( L, i );
lua_pushstring( L, sValue );
lua_settable( L, -3 );
}
// Now stack looks like -2: RowTable, -1: ColumnTable
// How do I do the equivalent of RT[ j ] = CT?
}
Any help would be greatly appreciated.
Michael
- References:
- LuaJIT performance, John C. Turnbull
- Re: LuaJIT performance, Mike Pall
- Re: LuaJIT performance, Alex Davies
- Re: LuaJIT performance, Michael Bauroth
- Re: LuaJIT performance, RJP Computing
- Re: LuaJIT performance, Asko Kauppi
- Re: LuaJIT performance, Alexander Gladysh
- Re: LuaJIT performance, Mike Pall
- Re: LuaJIT performance, Alexander Gladysh
- Re: LuaJIT performance, Mike Pall
- Re: LuaJIT performance, Mark Hamburg
- Re: LuaJIT performance, Tony Finch
- Re: LuaJIT performance, Mark Hamburg