Re: initializer for array of array

  • From: Alex <initrd.gz@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 7 Mar 2014 11:47:02 -0500

How so? That matches the behavior of most languages, including Lua itself.
Try it:

local t = {{1,2}, {3,4}, {5,6}}
print(t[1][1]) -- 1
print(t[2][1]) -- 3
print(t[3][2]) -- 6

(You will have to subtract one to try it with FFI arrays due to zero-based
indexing)



On Fri, Mar 7, 2014 at 11:37 AM, Victor Bombi <sonoro@xxxxxxxxxxxxxx> wrote:

>   Thanks
> my error was using
> ffi.new("float[2][3]", {{1, 2}, {3, 4}, {5,6}})
> instead of
>  ffi.new("float[3][2]", {{1, 2}, {3, 4}, {5,6}})
>
> this line would be very helpfull in luajit docs!!
>
> ----- Original Message -----
> *From:* Alex <initrd.gz@xxxxxxxxx>
> *To:* luajit@xxxxxxxxxxxxx
> *Sent:* Friday, March 07, 2014 3:34 PM
> *Subject:* Re: initializer for array of array
>
> This works for me:
>
> ffi.new("float[3][2]", {{1, 2}, {3, 4}, {5,6}})
>
>
> On Fri, Mar 7, 2014 at 4:41 AM, Victor Bombi <sonoro@xxxxxxxxxxxxxx>wrote:
>
>> Hello,
>>
>> I know it must be a trivial question but could not find in the help how
>> to initialize an array of arrays
>> ffi.new("float[3][6]",.....
>>
>> Best
>> victor bombi
>>
>>
>
>
> --
> Sincerely,
> Alex Parrill
>
>


-- 
Sincerely,
Alex Parrill

Other related posts: