From: BPJ via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: BPJ <bpj@melroch.se>
Subject: Re: Merging two lua tables
Date: Tue, 30 Aug 2022 10:56:19 +0200 [thread overview]
Message-ID: <CADAJKhBVsXNL4vSL9BR5nide4wanSyTGEGh66uxPKu5vBCz8nQ@mail.gmail.com> (raw)
In-Reply-To: <aec42127-a13f-15d0-46dd-94997f0f11b0@freedom.nl>
[-- Attachment #1.1: Type: text/plain, Size: 1890 bytes --]
Den mån 29 aug. 2022 20:13Hans Hagen via ntg-context <ntg-context@ntg.nl>
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
>
> ___________________________________________________________________________________
>
[-- Attachment #1.2: Type: text/html, Size: 3270 bytes --]
[-- Attachment #2: Type: text/plain, Size: 496 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2022-08-30 8:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 12:20 Aditya Mahajan via ntg-context
2022-08-29 12:29 ` Aditya Mahajan via ntg-context
2022-08-29 17:33 ` BPJ via ntg-context
2022-08-29 18:10 ` Hans Hagen via ntg-context
2022-08-30 8:56 ` BPJ via ntg-context [this message]
2022-08-30 10:08 ` BPJ via ntg-context
2022-08-29 14:28 ` Hans Hagen via ntg-context
2022-08-30 5:52 ` Aditya Mahajan via ntg-context
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADAJKhBVsXNL4vSL9BR5nide4wanSyTGEGh66uxPKu5vBCz8nQ@mail.gmail.com \
--to=ntg-context@ntg.nl \
--cc=bpj@melroch.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).