Re: [NTG-context] Merging two lua tables

2022-08-30 Thread BPJ via ntg-context
Come to think of it you may also want to check that numeric indices are indeed positive integers before appending their value. I usually don't because their not being so is rare. Den tis 30 aug. 2022 10:56BPJ skrev: > > > Den mån 29 aug. 2022 20:13Hans Hagen via ntg-context > skrev: > >> On

Re: [NTG-context] Merging two lua tables

2022-08-30 Thread BPJ via ntg-context
Den mån 29 aug. 2022 20:13Hans Hagen via ntg-context skrev: > On 8/29/2022 7:33 PM, BPJ via ntg-context wrote: > > Hi, > > > > I use the attached Lua function to merge array, map and mixed tables > alike > > (but differently! :-) The trick is to check if each key is numeric or > not, > > append

Re: [NTG-context] Merging two lua tables

2022-08-29 Thread Aditya Mahajan via ntg-context
On Mon, 29 Aug 2022, Hans Hagen via ntg-context wrote: > On 8/29/2022 2:20 PM, Aditya Mahajan via ntg-context wrote: > > Hi, > > > > How do I merge two lua tables? I believe that table.merge or table.merged > should do the trick, but I cannot figure out how to use them. > > > > ``` > > local t1

Re: [NTG-context] Merging two lua tables

2022-08-29 Thread Hans Hagen via ntg-context
On 8/29/2022 7:33 PM, BPJ via ntg-context wrote: Hi, I use the attached Lua function to merge array, map and mixed tables alike (but differently! :-) The trick is to check if each key is numeric or not, append if it is and overwrite if it isn't. you really want something like this then:

Re: [NTG-context] Merging two lua tables

2022-08-29 Thread BPJ via ntg-context
Hi, I use the attached Lua function to merge array, map and mixed tables alike (but differently! :-) The trick is to check if each key is numeric or not, append if it is and overwrite if it isn't. This function just ignores non-table arguments because that is what I usually want. You may want to

Re: [NTG-context] Merging two lua tables

2022-08-29 Thread Hans Hagen via ntg-context
On 8/29/2022 2:20 PM, Aditya Mahajan via ntg-context wrote: Hi, How do I merge two lua tables? I believe that table.merge or table.merged should do the trick, but I cannot figure out how to use them. ``` local t1 = { 1, 2 } local t2 = { 8, 9 } local m1 = {} table.merge(m1,t1, t2)

Re: [NTG-context] Merging two lua tables

2022-08-29 Thread Aditya Mahajan via ntg-context
On Mon, 29 Aug 2022, Aditya Mahajan via ntg-context wrote: > Hi, > > How do I merge two lua tables? I believe that table.merge or table.merged > should do the trick, but I cannot figure out how to use them. > > ``` > local t1 = { 1, 2 } > local t2 = { 8, 9 } > > local m1 = {} >

[NTG-context] Merging two lua tables

2022-08-29 Thread Aditya Mahajan via ntg-context
Hi, How do I merge two lua tables? I believe that table.merge or table.merged should do the trick, but I cannot figure out how to use them. ``` local t1 = { 1, 2 } local t2 = { 8, 9 } local m1 = {} table.merge(m1,t1, t2) table.print(m1) local m2 = table.merged(t1, t2) table.print(m2) ```