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 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: >> >> local tab = table.pack(...) >> local rv = {} >> > > Thanks. I was manually translating from MoonScript (https://moonscript.org) > where variables are local by default. > > >> > This function just ignores non-table arguments because that is what I >> > usually want. You may want to throw an error instead. Also it uses >> > table.pack. You might need to use `tab = {...}` and ipairs, or implement >> > pack: >> I might add table.himerged (hash and index) but slightly different (and >> some 30% faster) to util-tab but i think merging mixed hash/indexed >> tables is rare. >> >> Hans >> >> ----------------------------------------------------------------- >> Hans Hagen | PRAGMA ADE >> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands >> tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl >> ----------------------------------------------------------------- >> >> ___________________________________________________________________________________ >> If your question is of interest to others as well, please add an entry to >> the Wiki! >> >> maillist : ntg-context@ntg.nl / >> https://www.ntg.nl/mailman/listinfo/ntg-context >> webpage : https://www.pragma-ade.nl / http://context.aanhet.net >> archive : https://bitbucket.org/phg/context-mirror/commits/ >> wiki : https://contextgarden.net >> >> ___________________________________________________________________________________ >> >